The entity type 'Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin' requires a key to be defined

前端 未结 1 919
太阳男子
太阳男子 2020-11-28 12:08

I have a ASP.NET5 MVC application using EF7. It works all fine so far and i\'m able to add migrations and persist data in the database. Now after adding Identity to my data

1条回答
  •  迷失自我
    2020-11-28 12:36

    Basically the keys of Identity tables are mapped in OnModelCreating method of IdentityDbContext and if this method is not called, you will end up getting the error that you got. This method is not called if you derive from IdentityDbContext and provide your own definition of OnModelCreating as you did in your code. With this setup you have to explicitly call the OnModelCreating method of IdentityDbContext using base.OnModelCreating statement. This answer also discusses the option I posted here

    0 讨论(0)
提交回复
热议问题