2

I have an entity 4.0 model that is using a SqlServerCE database as its provider. I am trying to add a SQL Server Connection string so that, I can use choose to use either SQL Server or SQLCompact database.

Here is my Connection String

<?xml version="1.0" encoding="utf-8"?>      
<configuration>     
 <configSections>    
 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 </configSections>          

 <connectionStrings>    
 <--<add name="SomeDBEntities" connectionString="metadata=res://*/SomeDB.csdl|res://*/SomeDB.ssdl|res://*/SomeDB.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;Data Source=ABC.sdf&quot;" providerName="System.Data.EntityClient" />-->    

 <add name="SomeDBEntities" connectionString="metadata=res://*/SomeDB.csdl|res://*/SomeDB.ssdl|res://*/SomeDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=Database;Initial Catalog=MyDatabase;Integrated Security=True;multipleactiveresultsets=True;&quot;" providerName="System.Data.EntityClient" />      
 </connectionStrings>    
 <entityFramework>    

 <!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">    <parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
 </defaultConnectionFactory>-->

 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
 <parameters>      

 <parameter value="Data Source=Database;Integrated Security=True;multipleactiveresultsets=True" />    
 </parameters>
 </defaultConnectionFactory>

<-- -->

When I attempt to query the Entity Model, I get the following error: SqlCeCommand.CommandTimeout does not support non-zero values.

How do I set the provider from SqlServerCE to SqlClient?

user2330678
  • 2,221
  • 14
  • 43
  • 67

1 Answers1

0

The SqlServerCE provider is specified in the edmx file.

You need to create a Second SSDL File as it is described here : http://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov.aspx

Stanislav
  • 4,389
  • 2
  • 33
  • 35