EF Code First Migration with Multiple Database / DbContext

点点圈 提交于 2019-11-30 04:00:41

I've been able to answer my own question. My two configuration classes existed in the same namespace. As soon as I separated them, everything worked.

With Entity Framework 6 it's easy.

It's the same procedure for both multiple DbContexts for one database and for multiple DbContexts for each their own database:

Enable-Migrations -ContextTypeName <DbContext-Name-with-Namespaces> -MigrationsDirectory:<Migrations-Directory-Name>

Add-Migration -configuration <DbContext-Migrations-Configuration-Class-with-Namespaces> <Migrations-Name>

Update-Database -configuration <DbContext-Migrations-Configuration-Class-with-Namespaces> -Verbose

Source

NicoJuicy

It's been a while, but this could be a better answer to your problem :)

Update-Database -ConfigurationTypeName "SlaveConfiguration"
                -StartupProjectName "FacturatieMVCv2.Data" -Verbose 
                -ConnectionString "connstring;" 
                -ConnectionProviderName "System.Data.SqlClient"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!