Migrate multiple databases in EF and migrate multiple databases in ef

Source: Internet
Author: User

Migrate multiple databases in EF and migrate multiple databases in ef

Entity Framework allows you to create and update databases based on entities. When there is only one DBContext in the project, you can use the default parameters to perform database operations. When there are multiple DbContext, you need to set parameters to complete the corresponding operations. Multiple DbContext is common in actual development.

Take the Database Migration as an example. during Migration of a single Database, general steps 1, Enable-Migrations 2, Add-Migration, Migration name 3, and update-Database are acceptable. If the project contains multiple DbContext, if you do not specify the parameter, the system does not know which DbContext to migrate, migration steps for multiple dbcontexts 1. Enable-Migrations-ContextTypeName The Name Of The DbContext to be migrated 2. Add-Migration-ConfigurationTypeName the Configuration-Name generated in the previous step. 3. Update-Database- configuration generated in the first step of ConfigurationTypeName

If you do not specify a folder for the migration code, vs will automatically add a folder to the project. In this folder, you can see a Configuration. cs file. You can use this file for every migration of the ConfigurationTypeName parameter.

 

Related Article

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.