更改实体框架 4 中的 ConnectionString

发布于 2024-09-10 07:03:40 字数 244 浏览 3 评论 0原文

我正在努力更新旧系统,并且我们正在引入实体框架来实现一些新功能。然而,系统太大,无法一步完成迁移,因此我想在更新数据库模式之前在另一个数据库中进行一些测试。

我创建了一个空模型,包含数据库中的几个表,并从头开始添加了几个新实体,以及这些实体与旧表之间的关系。现在我想使用我的设计模型在另一个数据库中创建一个新的数据库模式,但我不知道如何进行切换,以便单击“从模型更新数据库...”将无法使用旧数据库,但与新的。

有没有直接的方法来做到这一点?

I'm working on updating an old system, and we're introducing Entity Framework for some new functionality. The system is, however, too large to do the migration in one step, so I would like to do some testing in another database before updating the db schema.

I have created an empty model, included a couple of tables from the database, and added a couple of new entities from scratch, along with relationships between these entities and the old tables. Now I want to create a new database schema in another database with my desing model, but I can't figure out how to switch so that clicking "Update database from model..." won't work with the old database, but the with the new one.

Is there a straight-forward way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱情眠于流年 2024-09-17 07:03:40

简而言之,连接设置位于您的配置文件或数据连接中。 实体框架连接和模型提供官方文档。

如果您的连接设置位于配置文件(即 Web.config / App.config)中,则可以在那里更改它们(其他文档位于 实体框架配置文件设置)。如果您使用 EF 设计器创建模型,则在配置文件中保存设置的选项位于 选择数据连接对话框(生成数据库向导)

如果您的连接设置不在配置文件中,则它们位于 Visual Studio 中服务器资源管理器的数据连接中:“查看”>“服务器资源管理器;展开数据连接,右键单击连接并选择修改连接。

In short, the connection settings are in your config file or a Data Connection. Entity Framework Connections and Models provides official documentation.

If your connection settings are in your config file, i.e. Web.config / App.config, you can change them there (additional documentation available in Entity Framework Config File Settings). If you used EF Designer to create your model, the option to save settings in the config file was in the Choose Your Data Connection Dialog Box (Generate Database Wizard).

If your connection settings aren't in a config file, they live in the Data Connection in the Server Explorer in Visual Studio: View > Server Explorer; expand Data Connections, right-click on the connection and choose Modify Connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文