Can't use migrations in EF Core: “42P07: relation ”AspNetRoles“ already exists”

后端 未结 2 967
独厮守ぢ
独厮守ぢ 2021-01-13 02:03

I have strange issue which I can\'t find solution for.

The stack is: NET Core 2, EF, PostgreSQL. I use .NET Core Identity with User : IdentityUser to ex

2条回答
  •  盖世英雄少女心
    2021-01-13 02:05

    The reason was pretty simple. I was calling EnsureCreated in Startup.cs which was getting conflict with migrations as working different way. Thankfully EF Core owners made it clear for me on GitHub.

    So to summarize - if you want to use Migrations, you can't use EnsureCreated.

提交回复
热议问题