我有一个实体 4.0 模型,它使用 SqlServerCE 数据库作为其提供程序。在服务器上,我想使用相同的项目,只需切换连接字符串以使用实际的 SqlServer 数据库。
这是我的连接字符串
<add name="Entities"
connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;
provider=System.Data.SqlClient;
provider connection string="
Data Source=xxxx;
Initial Catalog=xxxx;User ID=xxxx;Password=xxxx;""
providerName="System.Data.EntityClient" />
当我尝试查询实体模型时,出现以下错误:
SqlCeCommand.CommandTimeout does not support non-zero values.
如果我将上下文超时设置为 0,它会说
Unable to cast object of type 'System.Data.SqlClient.SqlConnection'
to type 'System.Data.SqlServerCe.SqlCeConnection'.
如何将提供程序从 SqlServerCE 设置为 SqlClient?
您需要做更多的工作,而不仅仅是交换连接字符串来支持不同的提供程序。本文介绍了如何支持多个提供商:
准备实体框架模型以支持多提供商 http://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov.aspx
本文介绍了对 VistaDB 和 SQL Server 的支持,但适用相同的原则。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)