0

I am hoping someone can give me some advice on how to implement a second database to handle user roles and passwords. The SQL database schema that contains all of the application data for my site can not be modified in any way. It does maintain a table with some user info, but nothing for password and role/access level. I want this table to be the master, and have a second table in a different DB maintain all the login and role info for each one of the users. How do I go about implementing that in my asp.net-MVC site?

2
  • thats actually Entity framework related question, not related to MVC, added a proper tag. Commented Jul 8, 2015 at 22:37
  • Thanks. I realized that as I was just posting a second question regarding EF. Commented Jul 8, 2015 at 22:45

2 Answers 2

1

Take a look at ASP.NET Identity.

http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity

The following should also help:

http://benfoster.io/blog/aspnet-identity-stripped-bare-mvc-part-1

http://benfoster.io/blog/aspnet-identity-stripped-bare-mvc-part-2

Sign up to request clarification or add additional context in comments.

1 Comment

I looked at both of those. They helped me understand more about the authentication and identity, but I am still struggling to understand how to make my app reference the local DB for just the authentication aspect. I think I am going to need to different dbcontext classes, but I just cant figure out how or where the Account controller knows what context to reference.
0

So the problem I was really having was that when ever I tried registering or logging in I would get the SQLServer error - 50. It would never create the DB like it should have. Finally I found this link, and it fixed my problem, SQL Server Express WebLog

As for using two different databases, I just need the two connection strings in web.config, and two DBcontext classes for the two different connections.

For the user data:

   public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("DefaultConnection")
    {
    }
}

and for all of the application data:

public partial class SomeEntities : DbContext
{
    public SomeEntities()
        : base("name=SomeEntities")
    {
    }
}

and the web.config file:

 <connectionStrings>
     <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-SomeScheduler-20150310115216.mdf;Initial Catalog=aspnet-SomeScheduler-20150310115216;Integrated Security=True" providerName="System.Data.SqlClient" />
     <add name="SomeEntities" connectionString="metadata=res://*/Models.Q-MakModel.csdl|res://*/Models.SomeModel.ssdl|res://*/Models.SomeModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=FileServer;initial catalog=SomeDATA;persist security info=True;user id=id;password=idp;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.