Reputation: 3893
How do I add Asp.net Identity tables such as
AspNetUsers
AspNetRoles
into my existing database?
I use VS Express 2013 for Web and SQL Server 2008. I ran
aspnet_regsql.exe
located under
C:\Windows\Microsoft.NET\Framework\v4.0.30319\
but it generated a bunch of tables that are for the old membership such as
aspnet_Users
aspnet_Roles
Please help me.
Upvotes: 0
Views: 3797
Reputation: 3893
I figured out. may helpful for others. Here is how:
from
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication4-20140129022205.mdf;Initial Catalog=aspnet-WebApplication4-20140129022205;Integrated Security=True"
providerName="System.Data.SqlClient" />
to
<add name="AuburnConnection" connectionString="Data Source=COLADT014\SQLEXPRESS;Initial Catalog=Auburn;Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
In IdentityModels.cs, replace "DefaultConnection" with "AuburnConnection":
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
}
with
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("AuburnConnection")
{
}
}
Run application and register a user.
All those asp.net Identity tables appear in your database.
Upvotes: 3