This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20194|Reply: 1

[.NET Core] Use EF Core MySQL data migration operations in .NET Core

[Copy link]
Posted on 6/21/2019 8:51:59 AM | | |
This post was last edited by Summer on 2019-6-21 09:57

These are the pitfalls encountered in data migration:
https://www.itsvse.com/thread-7720-1-1.html
https://www.itsvse.com/thread-7721-1-1.html
https://www.itsvse.com/thread-7722-1-1.html

1. Open vs2017 and create a new project
2. vs will automatically generate a project, and then open NuGet searchPomelo.EntityFrameworkCore.MysqlDownload

3. Then create a new entity class under Models, and then create a new class to inherit the DbContext class
4. Then we add a connection string to the appsettings.json (.NET Core uses to read the configuration in the appsettings.json, similar to webconfig)
5. Then open Startup and inject MySQL connection into services
6. Then we can start the data migration
Enter the following two commands in the Package Manager Console in VS:

Then we can see the generated database and data table in the database

To add, about setting up the launch,
Set the UI interface.mvc project as the startup item, right-click the project - Properties - Startup Object or even the project
The main thing is to set the project containing the "Migration" folder as the default project in the "Package Manager Console", the "Default Project" menu
Then in execution
operation.




Previous:Use case-ignoring strings in C#. Contains method
Next:HTTP traffic redirected to HTTPS configuration tutorial
Posted on 2/25/2023 6:57:54 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com