Knowledge - Details


New ASP.NET project fails to create database with Code-First Migration
Date Added: 9/17/2020

ASP.NET projects assume you are going to use Microsoft SQL Server, so when they create the default database Migration scripts, the scripts with MSQL commands. If you configure the project to use MySQL or some other database, you have to delete the default Migration scripts and tell Visual Studio to generate new ones. The new ones will automatically use the correct MySQL commands.

1) Delete the migration scripts

2) Run this in the Package Manager Console:

dotnet ef migrations add InitialDatabaseCreation

This will create the new Migration scripts.

3) Run this in the Package Manager Console:

dotnet ef database update

This will run the scripts on the database specified in the app.config file, creating the necessary tables and schema.

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/865



Back to List