Migration of. Net Core databases

Source: Internet
Author: User
Tags dotnet

Database migration mode: PMC (Package Management Controller), CLI (the directory console operation where the program resides)

  

1: Configure database information in Appsetting.json before migrating the database

  

  Note: both the entityframeworkcore.tools and Entityframeworkcore.sqlserver plugins are introduced on the NuGet Package Manager .  

2:CLI Database Migration

A: You first need to add a reference to the library in the project file

<dotnetclitoolreference include= "Microsoft.EntityFrameworkCore.Tools.DotNet" version= "2.0.2"/>

The version number depends on the actual situation of your project.

B: In the control form where the project is located, enter the command dotnet EF migrations Add initalcreate,initalcreate can be arbitrarily named. After executing this line, the Migrations folder will be found in the project.

The generated file data is inside, the Initalcreate file has two rewrite methods up, Down,up represents the transferred data form, DOWNB represents the data form before the transfer

C: Now you need to build the database, execute the command dotnet EF database update

 Note: If there is no problem with the above steps, the database has been generated. But if there is a problem, please pay attention to whether the lack of reference, Baidu solve it yourself.

2:PMC (Package Management Controller)

This is relatively simple.

A: Find package management Controller

B: In the console input command: Add-migration in the name of the random input English name update-database

Note: If the database has been generated successfully without error, if there is a problem

If you have any shortcomings, please advise friends, thank you ...

  

Migration of. Net Core databases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.