EF Core Migration with multiple provider always runs SQL Server scripts

.net c# entity-framework entity-framework-core

Question

I am using EF Core Code first and I have an issue when using multiple DB providers (SQL Server and MySql). Even when I choose to use MySql DB provider, SQL server migration files are used.

Check the sample project

1
0
4/12/2018 9:26:30 AM

Popular Answer

In my case, I use the same migration for both providers but sometimes I need to do some changes to migration files manually. for example added annotation for both providers (or change the type of some fields like varchar to nvarchar).

Id = table.Column<int>(nullable: false)
           .Annotation("MySql:ValueGeneratedOnAdd", true)
           .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),

For me it's work fine

1
4/12/2018 9:37:04 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow