Search code examples
ef-code-firstasp.net-identity-2

OnModelCreating fails when Context inherits from IdentityDbContext


I had Data access implemented as below and was working

  1. Contexct inheriting from DB Context
  2. Had OnModelCreating for configurations
  3. Manually addding configurations

However I modified my context to inherit from IdentityDbContext<ApplicationUser> and stopped manually generating configurations and after that the OnModelCreating fails and DB updates not happening at all.

If I remove the OnModelCreating, it works fine. As soon as I run the application.

Can any one guide me whats going wrong here?


Solution

  • I was missing the below line in the OnModelCreating method override. After that it started working.

    base.OnModelCreating(modelBuilder);