Changing default database of Identity/Membership authentication in ASP.NET MVC 5.1

asp.net-identity asp.net-mvc-5.1 c# connection-string entity-framework

Question

I currently started a new project in Visual Studio 2013 with ASP.NET MVC5 using Entity Framework Model-First. With entity is all fine, by now... haha

My question is: There's any way to change the database of Identity without overwriting it?

Explaining better: Currently, my database generated from Entity is well in my external SQL Server database, but my account information is in (I guess it) the SQL Server that run with Visual Studio 2013.

Reinforcing it: I just want to change the database to be the same as my Entity Framework is using, I don't want to overwrite it. Is it possible?

1
4
6/23/2014 5:00:08 PM

Accepted Answer

You have to change the ConnectionString to point to the database that you want. Identity uses EF to create the database and schema. Alternatively you can pass in the ConnectionString of your EF database to the IdentityDbContext. For example, in this sample, DefaultConnection is the name of the ConnectionString used by my EF Context and Identity Context:

public class MyDbContext : IdentityDbContext<ApplicationUser>
    {
        public MyDbContext()
            : base("DefaultConnection")
        {
        }
    }
8
2/4/2015 4:41:40 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow