请问Entity Framework 怎么使用自定义连接字符串?
因为数据库有很多个,还会不断增加,结构都是一样的,所以连接字符串无法写在config里
请问Entity Framework 怎么使用自定义连接字符串?
[解决办法]
数据库很多,webconfig里这样写不行吗?具体连哪个,指定DbConnection的ConnectionString属性不就行了?
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=
[解决办法]
DataDirectory
[解决办法]
aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="DB1"
connectionString="Data Source=xxx\xxxx;Initial Catalog=xxx;Integrated Security=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
<add name="DB2"
connectionString="Data Source=xxx;Initial Catalog=xxx;Integrated Security=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<configuration>
<connectionStrings>
<add name="HonorEntities" connectionString="metadata=res://*/HonorData.csdl
[解决办法]
res://*/HonorData.ssdl
[解决办法]
res://*/HonorData.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.;Initial Catalog=Honor;Persist Security Info=True;User ID=sa;Password=sa;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>