简体   繁体   English

在MVC实体框架中将数据库添加到web.config和外部数据模型edmx

[英]Adding a database to web.config & External Data Model edmx in MVC Entity Framework

I am extending an existing project by adding a new process which will reside on an existing project's website (and use the same look/feel) but the new process does not interact with the existing processes. 我通过添加新流程来扩展现有项目,该流程将驻留在现有项目的网站上(并使用相同的外观),但是新流程不会与现有流程交互。 In other words, I'm adding a new feature. 换句话说,我要添加一个新功能。

The database I'm going to create will reside on the same SQL instance as the existing project's database. 我要创建的数据库将与现有项目的数据库位于同一SQL实例上。 The existing connection string in the web.config has the initial catalog set to the existing project's database. web.config中现有的连接字符串将初始目录设置为现有项目的数据库。 I will need to switch to the new database for the pieces of the project I'm going to create. 对于将要创建的项目,我将需要切换到新数据库。 Do I need to add a new connection string to the web.config? 我是否需要向web.config添加新的连接字符串? Or is there a way to reference the new catalog using the existing connection string? 还是有一种方法可以使用现有的连接字符串来引用新目录?

I created a separate edmx. 我创建了一个单独的edmx。 To keep things organized, I placed it in a separate project folder in my solution, so the original edmx is in one folder, and the new edmx is in a separate folder. 为了使事情井井有条,我将其放在解决方案的单独项目文件夹中,因此原始edmx位于一个文件夹中,而新edmx位于一个单独的文件夹中。 I also have a separate app.config in each folder. 我在每个文件夹中都有一个单独的app.config。 So, my new folder is structured in the same way as the original one. 因此,我的新文件夹的结构与原始文件夹相同。

New Folder for my data model additions to the original project: 我的数据模型添加到原始项目的新文件夹:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不更新Database First Entity Framework MVC应用程序中的其他模型的情况下,向模型(edmx)添加新表 - Adding a new table to model (edmx) without updating the other models in Database First Entity Framework MVC application 使用实体框架自动生成控制器/模型时出错-Web.Config - Error Auto Generating Controller / Model with Entity Framework - Web.Config 数据库优先实体框架更新 EDMX 但不是 Model.tt - Database First Entity Framework Update EDMX but not Model.tt 使用Entity Framework时,如何将数据库用户名和密码安全地存储在web.config文件中 - How can a database username and password be stored securely in a web.config file when using Entity Framework 使用Entity Framework CodeFirst从Web.config中删除ConnectionString - Remove ConnectionString from Web.config using Entity Framework CodeFirst 实体框架无法在Web.config中找到连接字符串 - Entity Framework Can't Find Connection String in Web.config 实体框架-使用Web.Config连接字符串 - Entity Framework - Use Web.Config Connection String 实体框架无法在嵌套的web.config中找到连接字符串 - Entity Framework unable to find connection string in nested web.config 从实体框架web.config获取连接字符串 - Get connection string from Entity Framework web.config 如何在web.config中更改实体框架的连接字符串 - How to change connection string in web.config for entity framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM