Merge MyDbContext with IdentityDbContext

前端 未结 8 1864
天命终不由人
天命终不由人 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: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();
    }
    

提交回复
热议问题