Knowledge - Details
New ASP.NET project fails to create database with Code-First Migration
Date Added: 9/17/2020
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
Disclaimer: Everything on this website is written for my own use. I disclaim any guarantees that the procedures and advice listed here are accurate, safe, or beneficial for anyone else. If you attempt to follow any procedures or advice shared here, you do it at your own risk. Part of IT work is knowing how to recover from problems.