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

后端 未结 2 943
独厮守ぢ
独厮守ぢ 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.

    0 讨论(0)
  • 2021-01-13 02:15

    I was doing something really dumb! I copied the connection string from another micro service and it had the wrong Database in the connection string - that database already had the table that the error was complaining about! Block Copy strikes again!

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