简体   繁体   English

部署数据库优先 C# ASP.NET MVC 应用程序 - 连接到不同的数据库

[英]Deploying database-first C# ASP.NET MVC app - connect to different database

I'm trying to deploy a database-first application I have created.我正在尝试部署我创建的数据库优先应用程序。 I'm using an .edmx file for the models.我正在为模型使用.edmx文件。 I've been using a local db for testing and building but now I'm to the point where I need to demo and get feedback.我一直在使用本地数据库进行测试和构建,但现在我到了需要演示和获得反馈的地步。 In order to deploy it, I changed the connection string to:为了部署它,我将连接字符串更改为:

<add name="Entities" 
     connectionString="metadata=res://*/Models.DBModels.csdl|res://*/Models.DBModels.ssdl|res://*/Models.DBModels.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=servername;Initial Catalog=CRMS;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

So that it would connect to the new database.这样它将连接到新数据库。 However, this doesn't work and I get a metadata path is not valid error.但是,这不起作用,我收到元数据路径无效错误。

This is my first database-first app.这是我的第一个数据库优先应用程序。 I supposed I could create another .edmx file based off the production database but there has to be an easier way.我想我可以基于生产数据库创建另一个.edmx文件,但必须有一个更简单的方法。

I met with a similar error but I ended up creating another.edmx file because sometimes there will be issues with EF internally when you try to move/change and rerun it.我遇到了类似的错误,但我最终创建了另一个 .edmx 文件,因为当您尝试移动/更改并重新运行它时,有时会在内部出现 EF 问题。

Try these links, might help solve the problem: Link-1 Link-2试试这些链接,可能有助于解决问题: Link-1 Link-2

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM