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.