Using WCF Data Services 5.6.0 with Entity Framework 6+


And now for some exciting news: you can finally use WCF Data Services with Entity Framework 6+! Today we are uploading a new NuGet package called WCF Data Services Entity Framework Provider. This NuGet package bridges the gap between WCF Data Services 5.6.0 and Entity Framework 6+. We were able to build this provider as an out-of-band provider (that is, a provider that ships apart from the core WCF DS stack) because of the public provider work we did recently.

Upgrading an existing OData service to EF 6

If you are upgrading an existing OData service to Entity Framework 6 or greater, you will need to do a couple of things:

  1. Install the WCF Data Services Entity Framework Provider NuGet package. Since this package has a dependency on WCF Data Services 5.6.0 and Entity Framework 6 or greater, some of the other NuGet packages in your project may be upgraded as well.
  2. Replace the base type of your DataService. For EF 5 or below, your data service should inherit from DataService<T> where T is a DbContext or ObjectContext. For EF 6 or greater, your data service should inherit from EntityFrameworkDataService<T> where T is a DbContext. See What’s the difference between DataService and EntityFrameworkDataService below for more details.

Creating a new OData service with EF 6

If you are creating a new OData service and would like to use Entity Framework 6 or greater, you will need to follow similar steps:

  1. Create your new project. I typically use an ASP.NET Empty Web Application for this, but you can use whatever you want. Note that if you do use the empty template, you may need to create an App_Data folder for Entity Framework to work properly with LocalDB.
  2. Install the WCF Data Services Entity Framework Provider NuGet package. Since this package has a dependency on WCF Data Services 5.6.0 and Entity Framework 6 or greater, some of the other NuGet packages in your project may be upgraded as well.
  3. Add a new WCF Data Service. It’s best if you ensure that your tooling is up-to-date as we occasionally fix bugs in the item template. Our latest tooling installer was released with WCF DS 5.6.0. It can be downloaded here.
  4. Replace the base type of the DataService that was generated by the item template. For EF 6 or greater, your data service should inherit from EntityFrameworkDataService<T> where T is a DbContext. See What’s the difference between DataService and EntityFrameworkDataService below for more details.

What’s the difference between DataService<T> and EntityFrameworkDataService<T>?

Historically the WCF DS stack required all WCF DS-based OData services to inherit from DataService<T>. Internally, the data service would determine whether the service should use the in-box EF provider, the in-box Reflection provider, or a custom provider. When we added support for EF 6, we utilized the new public provider functionality to allow the provider to ship separately. This will allow us, for instance, to use WCF DS 5.6.0 with either EF 5, 6, or some future version. However, the new public provider functionality comes with a little bit of code you need to write. Since that code should be the same for every default EF 6 WCF DS provider, we went ahead and included a class that does this for you. EntityFrameworkDataService<T> inherits from DataService<T> and implements all the code you would need to implement otherwise. By shipping this additional class, we literally made the upgrade process as simple as changing the base type of your service.

Feedback please

We are heads down on getting our stacks updated to support OData v4, so we’ve had very limited resources to focus on testing this provider. We have a few automated tests and have tried a number of ad-hoc tests. That said, our coverage could be better so… we’re going to rely on you, our dear customer, to provide feedback of whether or not this provider works in your situation. If we don’t hear anything back, we’ll go ahead and release the provider in a week or so.

Thanks,
The OData Team

Comments (79)

  1. Chris Richner says:

    Good News! I've tried to "Creating a new OData service with EF 6" and faced

    The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:Users***DocumentsVisual Studio 2012ProjectsODataEF6SampleODataEF6SampleWcfDataService.svc.cs 17 18 ODataEF6Sample

    Anyone else facing this? What's wrong?

  2. virtualknowledgehub says:

    Hi

      You haveany queries visit http://www.kbreducation.com

  3. virtualknowledgehub says:

    If you want to strong with .net , then follow http://www.kbreducation.com

  4. Anders Mad says:

    I get this:

    Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed

  5. bipy says:

    I also get this error:

    The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

    Any solutions?

  6. gregory valderrama says:

    Hi , i have the same error please fix  that

    The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

  7. Ditto on the:

    The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

    Any fixes?

  8. Nevermind the alpha2 Nuget package fixes this

  9. Same with this error:

    The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

    Anyone found a fix?

    I am yet to find any working MS WCF tutorial that works.

  10. biiiipy says:

    Instead of "Install-Package Microsoft.OData.EntityFrameworkProvider -Version 1.0.0-alpha1 -Pre", just execute "Install-Package Microsoft.OData.EntityFrameworkProvider -Pre".

  11. Ray Turner says:

    Hi,

    I have been getting the following error whilst hitting an upgraded WCF Data Service

    System.InvalidOperationException

    The resource contains value '<Complex Type Here>' which cannot be serialized.

    at System.Data.Services.LiteralFormatter.FormatRawLiteral(Object value)

    at System.Data.Services.LiteralFormatter.FormatAndEscapeLiteral(Object value)

    at System.Data.Services.LiteralFormatter.DefaultLiteralFormatter.FormatLiteralWithTypePrefix(Object value)

    at System.Data.Services.LiteralFormatter.DefaultLiteralFormatter.Format(Object value)

    at System.Data.Services.WebUtil.GetETagValue(Object resource, ResourceType resourceType, ICollection`1 etagProperties, IDataService service, Boolean getMethod)

    at System.Data.Services.WebUtil.CompareAndGetETag(Object parentEntityResource, Object parentEntityToken, ResourceSetWrapper container, IDataService service, Boolean& writeResponseForGetMethods)

    at System.Data.Services.DataService`1.CompareETagAndWriteResponse(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)

    at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)

    at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)

    at System.Data.Services.DataService`1.HandleRequest()

  12. chenjf2 says:

    Hi, ask a question about Edm.DateTime atom format:

    http://www.odata.org/…/atom-format

    default: yyyy "-" mm "-" dd "T" hh ":" mm [":" ss["." fffffff]]

    for example china beijing Time : 2013-10-10 08:00 , result to: 2013-10-10T00:00

    what can i do , change default format, to china format?

    thinks a lot.

    my email: 18552070@qq.com

    I'm sorray,My English bad, chinese as follow:

    ——————-

    你好,问一个关于WCF Data Service的Edm.DateTime序列化格式的问题,

    http://www.odata.org/…/atom-format

    默认格式:yyyy "-" mm "-" dd "T" hh ":" mm [":" ss["." fffffff]]

    比如 中文北京时间:2013-10-10 08:00,默认输出变成:2013-10-10T00:00

    (日期和时间中间多一个T,中文时差8小时)

    如何才能改成本地化的时间格式,这样显示对用户比较友好。

    非常感谢!

    我的邮箱:18552070@qq.com

  13. Chet says:

    The EntityFrameworkDataService<T> is not exposing properties such as CurrentDataSource of the parent DataService<T>. It has a method called CreateDataSource(). Am I missing something?

  14. Ray Turner says:

    Please disregard my previous question (error in FormatRawLiteral).  The problem disappeared after restarting visual studio.

    Thanks.

  15. Clayton C. Peddy says:

    When using the EntityFrameworkDataService, I would expect to be able to use CurrentDataSource and override CreateDataSource just as with DataService<T>. Am I missing something here? Thanks!

  16. Tarek Salah says:

    Please help me with this question:

    stackoverflow.com/…/wcf-data-services-5-6-entity-framework-6-0-1-code-first-with-vocabularies

    I'm facing a problem that Add Service Reference is not returning the properties of the fields that is generated from the edmx. For example this in the Reference.cs of the service is auto generated with WCF DataServices 5.6+EF5:

    <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15"

    FixedLength="false" Unicode="true" />

    when I use EF ver 6.0.1 the service reference includes this code of the IEdmModel:

    <Property Name="CategoryName" Type="Edm.String" />

    I need to return the full properties of the fields to the client

  17. Ralf Handl says:

    When addressing a collection of media entities, e.g.

       GET ~/Employees

    or the media resource of a single media entity, e.g.

       GET ~/Employees(1)/$value

    everything works fine, but when I address the media entity itself, e.g.

       GET ~/Employees(1)

    I now get the error message "To support streaming, the data service must implement IServiceProvider.GetService() to return an implementation of IDataServiceStreamProvider or the data source must implement IDataServiceStreamProvider."

    IServiceProvider.GetService() is implemented and returns an implementation of IDataServiceStreamProvider, and this works in the first two cases, but in the single entity access IServiceProvider.GetService() is now no longer called for type IDataServiceStreamProvider.

  18. Ralf Handl says:

    Complex types no longer work, addressing an entity or entity set results in the error message "The resource contains value '<name of complex type>' which cannot be serialized."

  19. Ralf Handl says:

    FunctionImports no longer work: the XxxEntities.cs file gets generated with invalid code:

       using System.Data.Objects;

       using System.Data.Objects.DataClasses;

           public virtual ObjectResult<SalesByYear_Result> SalesByYear(Nullable<System.DateTime> beginning_Date, Nullable<System.DateTime> ending_Date)

           {

               var beginning_DateParameter = beginning_Date.HasValue ?

                   new ObjectParameter("Beginning_Date", beginning_Date) :

                   new ObjectParameter("Beginning_Date", typeof(System.DateTime));

               var ending_DateParameter = ending_Date.HasValue ?

                   new ObjectParameter("Ending_Date", ending_Date) :

                   new ObjectParameter("Ending_Date", typeof(System.DateTime));

               return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<SalesByYear_Result>("SalesByYear", beginning_DateParameter, ending_DateParameter);

           }

    Neither the two namespaces nor the used types ObjectResult and ObjectParameter exist.

  20. Kevin Grigsby says:

    Has anyone had an issue with the $expand using this update?  Seems to not work for me.  I have posted a question to Stack Overflow here:

    stackoverflow.com/…/ef-6-wcf-data-services-5-6-odata-expand-not-working

  21. Jeremy Caney says:

    Using the Alpha 2 release from NuGet, I am able to compile the service, but when accessing it I receive the following exception:

    Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.

    Is anyone else having issues loading resources for the Alpha 2 release?  FWIW, my /bin/lc/ folders (e.g., /bin/ja/) contain the v5.6.0 versions of Microsoft.Data.Services.resources.dll, which I would assume the EntityFrameworkProvider utilizes.

  22. Jay Traband says:

    Unless I’m missing something, this release manages to completely omit all Referential Constraints from the metadata of any Code First EF model.  ( I haven’t tried a Database first model yet).  

    The spec is pretty clear that these should be supported

    http://www.odata.org/…/common-schema-definition-language-csdl

    and they were in the previous WCF Data Services release for Entity Framework 5.  But now they seem to be gone and the fact is not mentioned anywhere.  

    Am I missing something?

  23. Alic W says:

    @Jeremy Caney

    Same here, am using alpha2,

    using System.Data.Services.Providers;

    public class SomeDataService : EntityFrameworkDataService<SomeDBEntities>

    get a runtime error:

    The server encountered an error processing the request. The exception message is 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.'. See server logs for more details.

  24. John C says:

    I am also getting the error:

    The server encountered an error processing the request. The exception message is 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.'

    I am using the package 1.0.0-alpha2.

  25. John C says:

    RESOLVED

    I resolved the error…

    The server encountered an error processing the request. The exception message is 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.'

    by removing enums from my data model.  It seems OData does not support enum types and supplies us with this unfortunately misleading exception when you include them.

  26. Andriy says:

    Need Geography and Geometry support Entity Framework in OData Service using SQL Server, or some features to be able use SQL Geography.  

  27. Jeremy Caney says:

    John C: Wow, great catch!  Indeed, a very bizarre error message to throw.  I wonder if it's throwing an exception when trying to lookup a localized resource for that error.  Regardless, an unfortunate limitation; I'm fond of my enums, although I suppose it's easy enough to replace them with a lookup table whose values correspond to the enum values.  Not quite as elegant of syntax due to the need to cast enums as integers, but a perfectly acceptable compromise to get Data Services working with Entity Framework 6.0.  Thanks for digging into that, and for reporting back on your find.

  28. Sean Hanley says:

    The resource error is actually a second error. It seems the Entity Framework provider DLL is missing the string resources (resx file I'm guessing) for error messages. So actually you see an error trying to get an error message string! You have to look at the stack trace to see what error message it was trying to get and then go look it up in the resources for the parent Microsoft.Data.Services (server) DLL.

    In my case, it was "DataService_CannotPerformOperationWithoutETag", something to do with concurrency that wasn't an issue when using EF5. It only occurred on PATCH (update) requests, though (and possibly inserts, didn't attempt those) even though reading data seemed to work okay.

    We've since reverted back to EF5 until things smooth out.

  29. Glawen says:

    It seems that complex types no longer works with this provider. I have an entity with a complex type and everything is working fine with EF5 and Data Service 5.6, but as soon as I migrate to EF6 and use the new provider I have the following error when I try to do a query :

    The resource contains value '<fullname of the complex type>' which cannot be serialized.

    If I remove the complex type the issue disappear and everything seems to work fine.

    To be sure it wasn't an issue with my EDMX or my model, I have created from scratch a small, single entity, EDMX and I have exactly the same issue as soon as I start using complex types.

  30. Daniel says:

    I have the same problem like Chris. The required reference to the assembly "Microsoft.OData.Service, Version=5.6.0.0" is missing!

    Where can i find this assembly?

  31. Tom Geiger says:

    After updating.. I'm trying to add a new Service Operation to my Service and when I try to access my resource via CurrentDataSource.MyResource…   MyResource is no longer available.  Has this functionality chanced with the update?  How do I get access to MyResource from within my new Service Operation?

  32. Tim Brookins says:

    Function Imports are now located "above" CurrentDataSource…  

    Instead of:      this.CurrentDataSource.MyProc(),

    use:                this.MyProc()

  33. Tim Brookins says:

    Never mind the last post….garbage!

  34. Dennis Williams says:

    I first installed the alpha 1 and received the error message that many on here have:

    Error      16           The type 'Microsoft.OData.Service.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.OData.Service, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.     C:Realtime SourceRTR 6.xRTRServicesRTRWCFDataServiceRTRWCFDataServiceRTRWCFData.svc.cs                21           16           RTRWCFDataService

    I then read further to a post saying to install : Install-Package Microsoft.OData.EntityFrameworkProvider -Pre  and this will install alpha2.  When I do this my package manger has two errors :

    Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load type 'System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand' from assembly 'E

    ntityFramework.PowerShell, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."

    At C:Realtime SourceRTR 6.xRTRServicesRTRWCFDataServicepackagesEntityFramework.6.0.1toolsEntityFramework.psm1:698 char:31

    +     $domain.CreateInstanceFrom <<<< (

       + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

       + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load type 'System.Data.Entity.ConnectionFactoryConfig.AddProviderCommand' from assembly 'EntityFramework

    .PowerShell, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."

    At C:Realtime SourceRTR 6.xRTRServicesRTRWCFDataServicepackagesEntityFramework.6.0.1toolsEntityFramework.psm1:698 char:31

    +     $domain.CreateInstanceFrom <<<< (

       + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

       + FullyQualifiedErrorId : DotNetMethodException

    And I am no longer to access the Microsoft.OData namespace that I need to get the Provider EntityFrameworkDataService.  Any help at all would be greatly appreciated.

  35. to Anders Mad and .resources error says:

    The solution for me is that I had an enum usage inside my model…removing it make the error go away….hope this help !

  36. Richard Page says:

    I am stymied by the TypeMismatchRelationshipConstraint validation error referenced by @Alberto Silva in comments to the 5.5.0. The error was introduced in 5.4.0.  The error goes away with EF 6 but the new framework provider does not give me a viable upgrade path because of breaking changes. The lack of continuity is astonishing.

  37. Nad says:

    Hello,

    I have also the following error, but I don't have any enum in my model. I think the exception is throwed when the EntityFrameworkProvider execute this function System.Data.Services.Providers.ObjectContextServiceProvider.SetConcurrencyValues.

    But I don't know how to resolve it.

    Thanks for your help.

    <m:message>Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.</m:message>

  38. NielThomas says:

    This solution works as explained with EF 6.

    But it seems that the provider has a problem wrapping/escaping "{" and "}" when querying for entities.

    E.g. (from x in [entity] where x.Name == "{" select x) would fail.

    NB: We did not have this problem with EF 5.5 (bacause we did not have to use the WCF Data Services Entity Framework Provider)

    Any fixes?

  39. Philip Medaglia says:

    Do you plan on getting CurrentDataSource to work again . It useless for me with out it.

    I sure most of us will need to access the dbContext at some point for non trivial apps

  40. Rajeev Kumar says:

    CurrentDataSource no longer used to retrieve DBContext. Anyone idea about to retrieve DBContext' methods and properties?

  41. Chris_Pomerantz says:

    What I did to get around the CurrentDataSource problem was to override CreateDataSource to be this:

    protected override EntityFrameworkDataServiceProvider2<UCSEntities> CreateDataSource()

    {

       this._dataContext = new MyEntityDataSource();

       return new EntityFrameworkDataServiceProvider2<UCSEntities>(

           new DataServiceProviderArgs(this, this._dataContext, null, false));

    }

    Then add a new property for your data source like this:

    public MyEntityDataSource CurrentDataSource

    {

       get { return this._dataContext; }

    }

    This seems to work for me but I am having other issues. I think I'm going to have to revert back to a previous version of my project that doesn't use EF6, there are still too many issues.

  42. Adrian Hope-Bailie says:

    Hi Astoria Team,

    Any comments on the issues experienced so far? You asked for feedback, you got it.

    When can we expect a beta release?

    It's very difficult to do any product planning if we don't know when the stack we want to use will be released as production ready.

  43. Justin Zeng says:

    Is IODataRequestMessage documenting?

    I need to replaced the stream to compress request stream,

    but i don't know what to do!

  44. Piotr Kołodziej says:

    Guys,

    I have one question. We desperately need a way to access entity before data service returns it. We have to check if this entity with it's PK has been moderated positively (via querying third party system). I know it's strange but interceptors are really not the best place for that. Is there a way to hijack data service when it grabs entity from DB that he is about to return?

    Best

    Piotr Kołodziej

  45. Dragan Radovac says:

    Great news, thanks

  46. Dave Allen-Williams says:

    As an alternative to Chris Pomerantz's solution, if you don't want to override CreateDataSource then the CurrentDataSource can also be retrieved via reflection.  Details of my solution (effective for the alpha 2 version of the provider) are at stackoverflow.com/…/20896926

  47. Wig says:

    OK, slightly off topic. I've got the 5.6 Data Services nicely exposing my EF6 objects via WCF and it works well, however how do I make the service call asynchronous? Is there an easy way using the new Async and Await keywords or do I need to create callback functions etc…

    None of my Data Service objects have any Async methods – is there a way to get these created when referencing the service?

  48. Will.Rogers says:

    Yeah, the CreateDataSource issue and related lack of access to the underlying data context are proving to be an big oversight.

  49. Randy D says:

    It would be very helpful if this code would be released as open source like the entire Entity Framework 6 library.

  50. Bruno Leclerc says:

    In my case, the InitializeService(DataServiceConfiguration config) has never been called. I tried with InitializeService(IDataServiceConfiguration config), it's never called either.

    (VS2013 + .Net 45 + EF 6.0 + DataService 5.6 + project webforms+MCV+WebApi)

    Why ?

  51. Dave Allen-Williams says:

    Hi OData team, four months since the last EF Data Provider drop – 1.0.0 alpha 2 in October 2013 – and our team is barely still holding out for a fix regarding the issue Sean Hanley described where (PATCH) updates fail..  

    Do you have a roadmap for the next alpha or a beta?  

    Any estimated timeframe appreciated, need to figure out whether to roll back to EF5 in the interim..

  52. Charles Rice says:

    I'm with Dave Allen-Williams. We have been waiting to upgrade to EF 6 but this alpha release isn't cutting it.  Everyone of our entities has a complex object and we need full metadata.  I also agree with Randy D that it would be nice to get this open sourced like EF, Rx, and ASP.NET.  I know I personally would put in some extra time to try and get things more loosened up.   From looking at the code it's very difficult to extend or replace any portion of WCF DataService.   Having to go all the way down to IQueryable to make changes seems a bit extreme to me – we did it but it seems it was harder than it should have to be.  Also there are classes that are public like ResourceProperty but have private dictionary for customAnnotations and the method to add customAnnotations is marked internal.  So Microsoft can add annotations but I can't, without reflection.  Which limits us from doing our own custom metadata implementation.   We only use WCF DataService to query but out of everything this is the roadblock on our server code.

  53. Adam Caviness says:

    Concerning the MissingManifestResourceException exception mentioned by Jeremy Caney, Alic W, John C, and Nad: it appears System.Data.Services.UpdatableWrapper() calls a IConcurrencyProvider implemented in Microsoft.OData.EntityFrameworkProvider.dll.  (Dear WCF Data Services Team, I cannot find any PDB symbols for Microsoft.OData.EntityFrameworkProvider.dll on SymbolSource or any other symbol host so please publish those.)  My gut reaction after looking in the UpdatableWrapper() method is that since bool? checkForEquality is initialized as null that the IConcurrencyProvider implementation in Microsoft.OData.EntityFrameworkProvider.ddl may not be properly handling a null checkForEquality value.  It's been a problem for months, can we get an update to this provider or at least provide us with some clue of where you are development wise with WCF Data Services? Thanks.

  54. Fred Bao - MSFT says:

    Hi team,

    I am confused why it can work well with WCF Data Service5.6 + EF5 when I use a complex type like:

    public class Status

       {

           public long Level { get; set; }

       }

       public class Permission

       {

           public Guid Id { get; set; }

           public string Code { get; set; }

           public Status Status { get; set; }

       }

    However, when I upgrade to EF 6, it gives me this:

    The resource contains value 'ServerForEntityFramework6.Status' which cannot be serialized.

    Do I miss something?

    Thx.

  55. Net Industries says:

    +1 complaint for the error:

    Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.

    System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed.

      at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)

      at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)

      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)

      at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)

      at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)

      at System.Data.Services.TextRes.GetString(String name, Object[] args)

      at System.Data.Services.Providers.ObjectContextServiceProvider.SetConcurrencyValues(Object resource, Nullable`1 checkForEquality, IEnumerable`1 concurrencyValues)

      at System.Data.Services.UpdatableWrapper.SetETagValues(Object resourceCookie, ResourceSetWrapper container)

      at System.Data.Services.DataService`1.HandleDeleteOperation(RequestDescription description, IDataService dataService)

      at System.Data.Services.DataService`1.ProcessIncomingRequest(RequestDescription description, IDataService dataService)

      at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)

      at System.Data.Services.DataService`1.HandleRequest()

  56. Timo P. Becker says:

    Current alpha 2 package won't install with WCF Data Services 5.6.1 package (released last week) and yield a "Already referencing a newer version of 'Microsoft.Data.Services'." as it explicitly compares the version string against '5.6.0'.

    Make sure to install the proper WCF Data Services version (Install-Package Microsoft.Data.Services -Version 5.6.0) to get the provider package working.

    If you already installed WCF Data Services 5.6.1 and need to downgrade make sure to also downgrade the dependency packages by uninstalling them first. The dependency packages are Microsoft.Data.Odata, Microsoft.Data.Edm, System.Spatial, Microsoft.Data.Services and Microsoft.Data.Services.Client

  57. Soumyadev says:

    I have installed WCF data services 5.6.1 but still getting error while resolving EntityFrameworkDataService

    I have referenced System.Data.Services dll

    Have included namespace System.Data.Services.Providers

  58. DevAT says:

    Hi OData-Team,

    – Are there plans to make this provider open source?

    – What are your plans to release a final version?

    – Is this still an active project?

    Thank you for answering

  59. Chris Kopec says:

    Can this package support Odata 5.6.1. It gives me an error when I try to install it claiming that I'm using packages that are too new.

    Are there plans to productize this package and release a stable version?

  60. Jeremy Caney says:

    For those who haven't seen it, the following post is relevant to the future of WCF Data Services.  If Microsoft is considering abandoning the project, that helps explain why there hasn't been any updates on this provider.

    blogs.msdn.com/…/future-direction-of-wcf-data-services.aspx

  61. AdamCaviness says:

    Do I need to rollback to EF5?  Any update from the OData Team of what's going on with this provider would be greatly appreciated.

  62. Tom_Floor says:

    Any chanches on releasing a MSI installer?

  63. Razvan says:

    I'm getting the

    "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "System.Data.Services.resources" was correctly embedded or linked into assembly "Microsoft.OData.EntityFrameworkProvider" at compile time, or that all the satellite assemblies required are loadable and fully signed"

    exception when using a DbGeometry, not an enum type.

    What to do OData Team?

  64. Wayne Schwebel says:

    We are still getting the "The resource contains value '<name of complex type>' which cannot be serialized." error when using complex types with the following versions:

    WCF Data Services: 5.6.0 – 5.6.1

    Entity Framework: 6.0.0 – 6.1.1

    WCF Data Services Entity Framework Provider 1.0.0-alpha2

    We suspect the culprit is the provider. When will a new version be released that fixes this problem? It has been broken since 2013-10-02.

  65. Richard Page says:

    I get MissingManifestResourceException when updating an object with DataServiceContext.AttachTo.

    Steps to reproduce:

    * Get object, edit, update, SaveChanges -> OK

    * Get object, edit, detach, attachTo, update, SaveChanges -> Exception.

  66. Zoe Luo says:

    @Richard, I'm doing some investigation on EF6 provider and I tried to repro your failure, but there is no exception in my code. Can you provide the code and the dll version you use?

  67. Zoe Luo says:

    @Ralf Handl, "using System.Data.Entity.Core.Objects;" instead of "using System.Data.Objects;" should can solve the problem

  68. Zoe Luo says:

    @Soumyadev, did you install EF6 provider? There is a separate installer, please try "Install-Package Microsoft.OData.EntityFrameworkProvider -Pre" in the Package Manager Console

  69. Zoe Luo says:

    @Bruno Leclerc, the reason why InitializeService function does not be called is because that WepApi and WCF ds has some conflicts in Url routing, and Url like ~/service.svc can not be handed over to wcf ds and InitializeService can not be called.  Try add "RouteTable.Routes.IgnoreRoute("{resource}.svc/{*pathInfo}");" in Global.asax.cs to let webapi bypass ~/service.svc routing.

  70. Zoe Luo says:

    @Ralf Handl, for the functionimport issue, the cause should be 5.x DBContext generator is used. instead of the workaround i mentioned before, you can try to install 6.x EF tools from  http://www.microsoft.com/…/details.aspx which will install 6.x DBContext generator

  71. Patrick L says:

    This is not working for me: when I browse to the .svc page (http://localhost:61680/WcfDataService1.svc) I get

    "The resource cannot be found.  Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly."

    Any ideas please?

  72. trancoc@gmail.com says:

    Hi all,

    I used .netframework 4.5 wcf 5.6. and ef 6.

    I get errors

    The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.

  73. PatrickL says:

    This is STILL not working for me (despite several posts back and forth on partnersupport.microsoft.com/…/mpnaspnet): when I browse to the .svc page (http://localhost:61680/WcfDataService1.svc) I get

    "The resource cannot be found.  Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly."

    Why is it that such a basic bug in Visual Studio 2013 Update 3 can still be left unfixed about 6 weeks after its release? It makes WCF Data Services unusable in MVC projects (I should add that it seems to work in ASP.Net WebForm projects, but not in MVC ones…).  Very frustrating.

  74. PatrickL says:

    Update: I can now get things to work in a pure MVC project (WITHOUT WebApi) by installing the following Nuget package from the console:

    PM> Install-Package Microsoft.OData.EntityFrameworkProvider -Pre

    and modifying the WcfDataService1.svc.cs file as follows (to use EntityFrameworkDataService)

    using System.Data.Services.Providers; // added for EntityFrameworkDataService

    namespace MVC5WithWCFDataService

    {

       public class WcfDataService1 : EntityFrameworkDataService<TestPersonsEntities>

    However, if I add WebApi to the project the WCF Data Service stops working, I get the same error as before "The resource cannot be found".

    So WebApi is somehow interfering with the WCF Data Service ….

  75. PatrickL says:

    Solution (finally!) from Rene Zhang at Microsoft, after my suggesting (see my comment above) that WebApi messes up the routing: I needed to add the line

    routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

    to RegisterRoutes in RouteConfig.cs in App_Start!

      public class RouteConfig

       {

           public static void RegisterRoutes(RouteCollection routes)

           {

               routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

               // 17 Oct 2014 Added at Microsoft support suggestion: resolves the

               // "System could not find resource" problem when trying to use WCF Data Service after adding WebApi

               routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

               routes.MapRoute(

                   name: "Default",

                   url: "{controller}/{action}/{id}",

                   defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

               );

           }

       }

    }

    (see also stackoverflow.com/…/wcf-mvc-webapi-handlers-and-routing)

    Update: if the WCFDataService is not at the top level of the website, but is instead in a subfolder, eg Services/ of the site, then a corresponding IgnoreRoute line needs to be added to the RouteConfig RegisterRoutes method,  eg

               routes.IgnoreRoute("Services/{resource}.svc/{*pathInfo}"); // this allows WCFDataServices in the Services/ folder to be called

    )

  76. Teh Kok How says:

    Hi, I could point the browser to the root of the service that it lists the names of my exposed entity sets. However, as soon as I try with a more specific query (http://IP:53246/SalesWCFDataService.svc/Customers), the service breaks with the following stack trace. Searching for main error message in google doesn't return any useful help.

       <m:error xmlns:m="schemas.microsoft.com/…/metadata">

       <m:code/>

       <m:message xml:lang="en-SG">An error occurred while processing this request.</m:message>

       <m:innererror>

       <m:message>The value returned by IDataServiceMetadataProvider.ContainerNamespace must not be null or empty.</m:message>

       <m:type>System.InvalidOperationException</m:type>

       <m:stacktrace>

       at System.Data.Services.Providers.DataServiceProviderWrapper.get_ContainerNamespace()

       at System.Data.Services.Providers.MetadataProviderEdmModel.GetContainerNamespace()

       at System.Data.Services.Providers.MetadataProviderEdmModel.EnsureDefaultEntityContainer()

       at System.Data.Services.Providers.MetadataProviderEdmModel.EnsureEntitySet(ResourceSetWrapper resourceSet)

       at System.Data.Services.Providers.MetadataProviderEdmModel.Microsoft.Data.OData.Metadata.IODataUriParserModelExtensions.FindEntitySetFromContainerQualifiedName(String containerQualifiedEntitySetName)

       at Microsoft.Data.OData.Query.ODataPathParser.CreateFirstSegment(String segmentText)

       at Microsoft.Data.OData.Query.ODataPathParser.ParsePath(ICollection`1 segments)

       at Microsoft.Data.OData.Query.ODataPathFactory.BindPath(ICollection`1 segments, ODataUriParserConfiguration configuration)

       at Microsoft.Data.OData.Query.ODataUriParser.ParsePath(Uri pathUri)

       at System.Data.Services.RequestUriProcessor.ParsePath(Uri absoluteRequestUri, IDataService service)

       at System.Data.Services.RequestUriProcessor.ProcessRequestUri(Uri absoluteRequestUri, IDataService service, Boolean internalQuery)

       at System.Data.Services.DataService`1.ProcessIncomingRequestUri()

       at System.Data.Services.DataService`1.HandleRequest()

       </m:stacktrace>

       </m:innererror>

       </m:error>

  77. why not include wcf ds nuget package? says:

    i look at the ef provider in wcf ds lib 's namespace :System.Data.Services.Provider

    in this namespace a class name is EntityFrameworkDataServiceProvider, then i think

    how to change provider about for DataService<T> but i dont successed. i try a lot of way..

    alright use this alpha package..try again

  78. Scott Winterrowd says:

    When using wcf ds 5.6 with ef 6.1, I am trying to access sql database entities on the service side using the service operations examples that I have found. These examples all inherit from the dataserviceprovider and not the entityframeworkserviceprovider. I have been unable to access the table entities using the newest provider and the currentdatasource. I also have been unable to find an example or instructions on how to do so. Any direction would be appreciated.

    namespace NorthwindDataService

    {

       public class Northwind : EntityFrameworkDataService< NorthwindEntities>

       {

           public static void InitializeService(DataServiceConfiguration config)

           {

                           config.SetEntitySetAccessRule("Orders", EntitySetRights.AllRead);

               config.SetEntitySetAccessRule("Order_Details", EntitySetRights.AllRead);

               config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead);

                           config.SetServiceOperationAccessRule(

                   "GetOrdersByCity", ServiceOperationRights.AllRead);

               config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);

               config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;

          }

           [WebGet]

           public IQueryable<Order> GetOrdersByCity(string city)

           {

               if (string.IsNullOrEmpty(city))

               {

                   throw new ArgumentNullException("city",

                       "You must provide a value for the parameter'city'.");

               }

              EntityFrameworkDataServiceProvider2<NorthwindEntities> context = base.CurrentDataSource;

               try

               {

                   var selectedOrders = from order in context.Orders.Include("Order_Details")

                                        where order.Customer.City == city

                                        select order;

                   return selectedOrders;

               }

               catch (Exception ex)

               {

                   throw new ApplicationException(string.Format(

                       "An error occurred: {0}", ex.Message));

               }

           }

       }

    }