我发现了很多关于将 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/