web.config DbContext和ObjectContext的一个连接字符串

时间:2015-07-25 13:51:39

标签: c# entity-framework connection-string dbcontext objectcontext

在我的项目中,我已将部分业务升级为DbContext,之前的版本位于ObjectContext。 我希望在ConnectionStringweb.config DbContext中有一个ObjectContext

<add name="OjContext" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=server-pc;Initial Catalog=db;User ID=sa;password=123;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
<add name="DbContext" connectionString="Data Source=server-pc;Initial Catalog=db;User ID=sa;password=123;" providerName="System.Data.SqlClient" />

1 个答案:

答案 0 :(得分:0)

您需要使用EntityConnectionStringBuilder.ProviderConnectionString属性的“DbContext”连接字符串在代码中构建“OjContext”连接对象。

在此处查看更多内容:https://msdn.microsoft.com/en-us/library/vstudio/Bb738533(v=VS.100).aspx