我有一个使用 EF 的 ASP.Net MVC 项目。我在工作计算机和家用计算机上开发此应用程序。以下是在我的 Web.config 中。如何使用每个办公室的正确连接字符串更改 EDMX?到目前为止,我必须删除 EDMX 并重新添加它们并注释掉其他连接字符串。谢谢。
<connectionStrings>
<clear/>
<!-- At Home connections -->
<add name="App1Entities" connectionString="metadata=res://*/Models.App1Model.csdl|res://*/Models.App1Model.ssdl|res://*/Models.App1Model.msl;provider=System.Data.SqlClient;provider connection string="data source=my-pc\SqlExpress;initial catalog=App1Database;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="Service1Entities" connectionString="metadata=res://*/Models.Service1Model.csdl|res://*/Models.Service1Model.ssdl|res://*/Models.Service1Model.msl;provider=System.Data.SqlClient;provider connection string="data source=my-pc\SqlExpress;initial catalog=ServiceDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<!-- At Work connections
<add name="App1Entities" connectionString="metadata=res://*/Models.App1Model.csdl|res://*/Models.App1Model.ssdl|res://*/Models.App1Model.msl;provider=System.Data.SqlClient;provider connection string="data source=sqlServer1;initial catalog=App1Database;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="Service1Entities" connectionString="metadata=res://*/Models.Service1Model.csdl|res://*/Models.Service1Model.ssdl|res://*/Models.Service1Model.msl;provider=System.Data.SqlClient;provider connection string="data source=sqlServer2;initial catalog=ServiceDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
-->
</connectionStrings>