3

I have found lots of information about using Entity Framework 6 with Sql CE 4 and on using Entity Framework 4 with both Sql CE 4 and 3.5, but using Entity Framework 6 with Sql CE 3.5 is a different matter. As far as I can tell, CE 3.5 ships with a provider for Entity Framework 4 in System.Data.SqlServerCe.Entity.dll. This provider uses an older version of the base classes and if I try to use it, I get the following exception:

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.

This makes sense and points me to the realization that what I need is a provider for Entity Framework 6 for Sql Server CE 3.5 SP2. I can't seem to find such a thing though. The nuget package EntityFramework.SqlServerCompact seems to only reference Sql Compact 4 in all its versions. Does such a provider already exist? If so, where can it be found? I seem to be having difficulty locating it. If not, would it be realistic to think of implementing it by using the code in the one for CE 4 with a reference to 3.5, or is the difference between CE 3.5 and 4 too different for that to be straightforward? Is there another workaround?

I need to use 3.5 because of a need for using merge replication, which is not supported in 4, and would like to use Entity Framework. If there's not a straightforward answer to this, I'll probably use something other than Entity Framework.

Dave Rael
  • 1,759
  • 2
  • 16
  • 21

1 Answers1

9

OK, this is the second request I hear for this, let us do it. I will fork the code, and make a Nuget package for 3.5 - how about "EntityFramework.SqlServerCompact.Legacy" ? The "only" code change required is the fact, that 3.5 does not support ORDER BY..FETCH..OFFSET syntax (ie paging) called via Take and Skip. Would you be interested in this?

UPDATE: Package now available on NuGet http://www.nuget.org/packages/EntityFramework.SqlServerCompact.Legacy

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • yes, that does interest me and would be what i am seeking. paging is not a concern to me for my current project. i am willing to contribute - but sounds like there's not a lot to it given your statement that there's not much to change in the code. the name of the package you pitched works for me. – Dave Rael Nov 19 '13 at 14:13
  • Great, I am already on it - have you considered using LINQ to SQL instead? – ErikEJ Nov 19 '13 at 14:30
  • thanks erik, that is awesome. i have considered alternatives and would probably have used nhibernate instead had there not been this route to getting entity framework working. – Dave Rael Nov 19 '13 at 15:29
  • and is there something i could do to assist in your efforts on this? – Dave Rael Nov 19 '13 at 16:20
  • Would you like to contribute, then I can make you collaborator? https://entityframework.codeplex.com/SourceControl/network/forks/ErikEJ/SqlCe35Revival – ErikEJ Nov 19 '13 at 18:09
  • email sent. did you receive it? – Dave Rael Nov 20 '13 at 18:01
  • My greatest thanks for you Nuget. You saved my day ! – informaticienzero Oct 16 '17 at 09:42
  • @ErikEJ, are there any examples on how to use this? I can't find any examples for EntityFramework.SqlServerCompact.Legacy – Doctor Jones Aug 17 '18 at 11:42
  • I'm trying to use the EntityFramework.SqlServerCompact.Legacy nuget package, but keep getting an error saying the provider isn't registered, despite having it in my config file. I was hoping to find a complete working example online so I can see what's wrong. – Doctor Jones Aug 17 '18 at 13:18
  • Post a question on Stack with more details, pls – ErikEJ Aug 17 '18 at 13:21