Merge MyDbContext with IdentityDbContext

前端 未结 8 1812
天命终不由人
天命终不由人 2020-11-28 22:22

I have a MyDbContext in a separated Data Accass Layer class library project. And I have an ASP.NET MVC 5 project with a default IdentityDbContext. The two context use the sa

相关标签:
8条回答
  • 2020-11-28 23:14

    I tried a simple way.. copy the connection string from your db and replace the connection string of DefaultConnection. Go ahead and create user, all the necessary tables are automatically created in your database.

    Hope that helps

    0 讨论(0)
  • 2020-11-28 23:16

    The problem was caused because You overwrote the content of method "OnModelCreating" which is implemented in IdentityUser class.

    You need to call OnModelCreating method from the base class first, and after that add your code. So Your method OnModelCreating should look like this:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
         base.OnModelCreating(modelBuilder);
    
         modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
    }
    
    0 讨论(0)
提交回复
热议问题