c# - 用于 EF core 数据库更新的命令行连接字符串

标签 c# asp.net-core .net-core entity-framework-core entity-framework-migrations

使用 ASP.NET Core 和 EF Core,我尝试将迁移应用到数据库。但是,由于安全问题,应用程序将使用的 appsettings.json 中的连接字符串中的登录名仅具有 CRUD 访问权限,因此它无法创建表和列等。因此,当我运行:

dotnet ef database update -c MyDbContextName -e Development

我想告诉它使用不同的连接字符串,但我不知道这是否可以做到?基本上,我想使用两种不同的连接字符串,一种用于部署,一种用于运行应用程序。这可能吗?有更好的方法吗? 谢谢。

最佳答案

在 EF Core 5.0 中,您将像这样在命令行中传递连接字符串,

dotnet ef database update --connection "connection string"

引用: https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/whatsnew#new-command-line-parameters-for-namespaces-and-connection-strings

关于c# - 用于 EF core 数据库更新的命令行连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43398483/

相关文章:

c# - 从受密码保护的网站自动下载

c# - Nancy 在单独的库中提供来自模块的 View

asp.net-core - Automapper 和 EF 导航属性

c# - 是否可以使用 .net core c# 执行 ps -aux ?

c# - 连接到不安全的gRPC channel 时的"The response ended prematurely"

C# 模拟 Mock<StreamWriter>

c# - 复选框内容内的列表框 - WPF

c# - 项目中的依赖Twilio不支持框架DNXCore,版本=v5.0

c# - JSON 响应被相当小的数组截断

asp.net-core - 一个对象句柄有这么多TimerQueueTimer引用意味着什么