Net Core 2 - Entity Framework: Update-Database of different environment

≯℡__Kan透↙ 提交于 2019-12-03 09:41:27

Not well documented but you can have to changed the ASPNETCORE_ENVIRONMENT manually by running this command in Package Manager Console

PM> $env:ASPNETCORE_ENVIRONMENT='Staging'

then you can run this command to verify it is pointing to your desired database:

PM> Get-DbContext

which will kick out

providerName                            databaseName          dataSource                                 options
------------                            ------------          ----------                                 -------
Microsoft.EntityFrameworkCore.SqlServer myDatabase            tcp:fake.database.windows.net,1433           None

then just run your commands as normal. Example:

Update-Database

Reference to commands: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!