[Tutorial & Sample] WCF Data Services Entity Framework Provider is updated with WCF Data Service 5.6.2

Zoe Luo

After WCF Data Services Entity Framework Provider version 1.0.0-alpha2 was released, we got lots of valuable feedbacks from customers. Recently we summarized all the feedbacks and fixed the most critical bugs reported. Now we are happy to announce the release of WCF Data Services Entity Framework Provider 1.0.0-beta2 (Below using EF6 Provider beta2 for short).

  • Download sample code here.

Adopting EF6 provider beta2 in new service

1. Create a new project, an ASP.NET Empty Web Application in Visual Studio 2012 for example.

2. Install the EF6 Provider beta2 NuGet package. WCF Data Service 5.6.2 and Entity framework 6.0.1 will be installed as dependencies.

3. Create a data model with EF6

Follow instructions in this blog post to upgrade to EF6 and make sure you install EF 6.x DbContext Generator if using DB first development.

4. Add a new WCF Data Service 5.6.2. This item will be added into Visual Studio by installing WCF Data Service 5.6.2 tooling installer. (5.6.2 tooling installer will be published soon, currently you can add a WCF Data Service, and upgrade WCF Data Service dll to 5.6.2)


5. Replace the base type of the DataService that was generated by the item template with EntityFrameworkDataService. See the article What’s the difference between DataService and EntityFrameworkDataService for more details.

If you upgrade an existing service to EF6 provider beta2, you just need to upgrade EF provider Nuget package and make sure your data service inherits from EntityFrameworkDataService<T> where T is your data source class.

Bugs fixed in EF6 Provider beta2

Based on customers’ feedbacks of previous EF6 Provider, we got lots of bugs fixed in this version. Please refer to the release note for details. The top-voted issues “complex type” and “CurrentDataSource” are fixed as the highest priority.

1. Complex type can be serialized now

Complex type is supported in both DB First and Code First development. The following are examples of complex type scenario in each approach.

In DB First development, for example in DataBaseFirstSample, create a complex type “ShipInfo” in EF designer (Refer Complex Types in the EF Designer) to contain properties like “ShipName”, “ShipAddress”, etc. and class “ShipInfo” will be auto-created after saving.

Then complex property can be accessed with URL:


In Code First development, for example in CodeFirstSample, define a class named “PostContent”:

Define property “content” based on “PostContent” in entity type “Post”:

Then complex property can be access with URL:


2. CurrentDataSource on DataService class can be used to retrieve DBContext now

CurrentDataSource is used often in functions, and query or change interceptors. The following gives an example of using CurrentDataSource in function definition.

For example in DataBaseFirstSample service, define a function “GetOrdersCount” which accesses “Orders” through CurrentDataSource:

Then the function “GetOrdersCount” can be called with URL:


Apologize that we do not have enough time to support Enum and Spatial types in this version, service would fail to access if Enum or spatial type exists in data model.

Open source

The EF6 provider source code has been released under Apache 2.0 license. You can download the code from our Git repository at https://git01.codeplex.com/odata, or view more about OData at https://odata.codeplex.com/ . We continues our commitment to open source, and we are happy to receive community contributions and feedbacks.


Discussion is closed.

Feedback usabilla icon