[英]How to update Entity Framework Core after adding a new table to the database
[英]How to change connection string on command line to update database on migration to a new database in Entity Framework Core
在ASP.NET Core和EF Core Code First中,我有一个多租户webapp。 当我创建一个新租户时,我想更改连接字符串,在其上添加迁移然后更新。
从命令行,添加迁移无法在租户上获取连接字符串,因此我没有用于在应用程序以新租户启动时创建新数据库的有效连接字符串。 它有什么解决方案吗? 谢谢
你在找这个吗? 编辑 :这适用于EF 6.1
Update-Database –ConnectionString "Data Source=YourDatabaseServer; Initial Catalog=YourDatabase; Integrated Security=True;"
我通过在DbContext构造函数中插入来解决:
Database.EnsureCreated();
感谢您的回复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.