实体框架的使用模式不同的供应商 [英] Entity Framework use model for different providers

查看:120
本文介绍了实体框架的使用模式不同的供应商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体4.0模型是使用SqlServerCE数据库作为其供应商。在服务器我想用同一个项目,只是转出连接字符串使用实际的SQL Server数据库。

I have an entity 4.0 model that is using a SqlServerCE database as its provider. On the server I want to use the same project and just switch out the connection string to use the actual SqlServer database.

下面是我的连接字符串

<add name="Entities"
        connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;
provider=System.Data.SqlClient;
provider connection string=&quot;
Data Source=xxxx;
Initial Catalog=xxxx;User ID=xxxx;Password=xxxx;&quot;" 
providerName="System.Data.EntityClient" />

当我尝试查询的实体模型,我得到以下错误:

When I attempt to query the Entity Model, I get the following error:

SqlCeCommand.CommandTimeout does not support non-zero values.

如果我设置的背景下超时时间为0时,则说:

If I set the context timeout to 0, it then says

 Unable to cast object of type 'System.Data.SqlClient.SqlConnection'
 to type 'System.Data.SqlServerCe.SqlCeConnection'.

如何设置从SqlServerCE的供应商SQLCLIENT?

How do I set the provider from SqlServerCE to SqlClient?

推荐答案

您需要做更多的工作不仅仅是换出的连接字符串,以支持不同的供应商。本文介绍了如何支持多个供应商:

You need to do a bit more work than just swapping out the connection string to support different providers. This article explains how to support more than one provider:

<一个href="http://www.$c$cproject.com/Articles/82017/$p$pparing-an-Entity-Framework-model-for-multi-prov.aspx"相对=nofollow> preparing实体框架模型的多供应商支持

本文涵盖配套VistaDB的和SQL Server,但同样的原则也适用。

The article covers supporting VistaDB and SQL Server but the same principles apply.

这篇关于实体框架的使用模式不同的供应商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆