entity-framework - 带有 Sql Server Compact 3.5 SP2 的 Entity Framework 6?

标签 entity-framework sql-server-ce entity-framework-6 sql-server-ce-3.5

我发现了很多关于将 Entity Framework 6 与 Sql CE 4 一起使用以及将 Entity Framework 4 与 Sql CE 4 和 3.5 一起使用的信息,但是将 Entity Framework 6 与 Sql CE 3.5 一起使用是另一回事。据我所知,CE 3.5 在 System.Data.SqlServerCe.Entity.dll 中附带了 Entity Framework 4 的提供程序。此提供程序使用旧版本的基类,如果我尝试使用它,我会收到以下异常:

System.InvalidOperationException: The 'Instance' member of the Entity Framework provider type 'System.Data.SqlServerCe.SqlCeProviderServices, System.Data.SqlServerCe.Entity, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

这很有意义,并让我意识到我需要的是 Sql Server CE 3.5 SP2 的 Entity Framework 6 提供程序。不过,我似乎找不到这样的东西。 nuget 包 EntityFramework.SqlServerCompact 似乎只在其所有版本中引用 Sql Compact 4。这样的提供者是否已经存在?如果有,在哪里可以找到?我似乎很难找到它。如果不是,考虑使用 CE 4 中的代码并引用 3.5 来实现它是否现实,或者 CE 3.5 和 4 之间的差异是否太不同以至于不能直截了当?还有其他解决方法吗?

我需要使用3.5,因为需要使用合并复制,4不支持,并且想使用Entity Framework。如果没有直接的答案,我可能会使用 Entity Framework 以外的东西。

最佳答案

好的,这是我听到的第二个请求,让我们去做吧。我将 fork 代码,并为 3.5 制作一个 Nuget 包 - “EntityFramework.SqlServerCompact.Legacy”怎么样?所需的“唯一”代码更改是事实,即 3.5 不支持通过 Take and Skip 调用的 ORDER BY..FETCH..OFFSET 语法(即分页)。你会对此感兴趣吗?

更新:包现在可以在 NuGet http://www.nuget.org/packages/EntityFramework.SqlServerCompact.Legacy 上使用

关于entity-framework - 带有 Sql Server Compact 3.5 SP2 的 Entity Framework 6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20057834/

相关文章:

sql-server - Entity Framework 6 数据库首先不会在具有复合键的表上生成实体

c# - 处理 null 的 Linq 表达式

c# - 两个并行的 TransactionScope,每个都有自己的连接

c# - 如何过滤嵌套关系

c# - 使用 C# Entity Framework 控制传递到表中的数据类型的方法

c# - 如果我在我的应用程序中嵌入 SQL Server Compact Edition 4.0 x64,我可以在 x86 客户端上部署应用程序吗?

sql - 在 SQL 中转换日期

asp.net - Entity Framework - "New transaction is not allowed because there are other threads running in the session"

c# - 由同一台本地计算机上的多个应用程序并发访问轻量级/(嵌入式?)SQL 数据库?

c# - 带有嵌套选择的 Linq 查询