【发布时间】:2014-10-16 17:57:06
【问题描述】:
我正在尝试使用 Code First 私下部署带有实体框架 6 的 SQL CE WPF。
在开发机器上,数据库在 AppData 文件夹中生成正常,并且一切正常,但是在测试 PC 上我得到一个异常(无 db):
"The ADO.NET provide with invariant name 'System.Data.SQlServerCe.40' is either not registered in the machine or application config file'
我已尝试实施有关此问题的所有可用文献,但仍然存在问题。我已经使用 Deployed Folder 检查了 Bin 文件夹,它是相同的,所有库(x86 和 amd64)都存在并且项目平台目标是 x86。
- No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'
- http://erikej.blogspot.dk/2013/11/entity-framework-6-sql-server-compact-4_25.html
- Entity Framewok Code First "ADO.NET provider not found" with local SQL Server CE DLL's
下面是我的 App.config
<?xml version="1.0" encoding="utf-8"?>
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<contexts>
<context type="MyProject.DAL.GreatContext, MyProject">
<databaseInitializer type="MyProject.Module.Database.Dal.GreatDbInitializer, MyProject" />
</context>
</contexts>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
</configuration>
我也添加了波纹管代码,但问题仍然存在:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
有什么想法吗?
【问题讨论】:
-
您的项目中包含的 System.Data.SqlServerCe.dll 的程序集版本是什么?
标签: c# entity-framework sql-server-ce