0

试图让连接单独工作,但是它一直坚持找不到连接。

我的配置文件:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <connectionStrings>
    <add name="Tank_Analizor_DBEntities" connectionString="metadata=res://*/Analizor.csdl|res://*/Analizor.ssdl|res://*/Analizor.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=|DataDirectory|\DB\Tank_Analizor_DB.sdf&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0"/>
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

尝试直接将路径更改为数据库文件,例如:

    <add name="Tank_Analizor_DBEntities" connectionString="metadata=res://*/Analizor.csdl|res://*/Analizor.ssdl|res://*/Analizor.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=C:\Debug\DB\Tank_Analizor_DB.sdf&quot;" providerName="System.Data.EntityClient"/>

但仍然没有运气,这可能是什么问题?

4

1 回答 1

0

更新实体框架连接工厂设置。您是指向 sql server compact 的连接字符串,但连接工厂是为 sql server v11.0 配置的

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="System.Data.SqlServerCe.4.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>
于 2013-08-12T12:09:01.803 回答