[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Collapse]Scaffolding Wizard
   [Collapse]Data Access Layer
     How To: Generate Data Access Layer with Entity Framework Database First
     How To: Generate Data Access Layer with Entity Framework Code First
     How To: Generate Data Access Layer Based On Data Provided By a WCF Service
   [Expand]Generating an Application
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts to a File, Stream and System Registry
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How To: Generate Data Access Layer Based On Data Provided By a WCF Service

In this example you will create a Data Access Layer that works with the WCF Service, which retrieves data from a remote database.

  1. In Visual Studio, go to "File | New | Project" or press CTRL+SHIFT+N to create a new project. Select the "Blank Solution" template to create a solution with no projects.

  2. Right click the solution in Solution Explorer window, then click "Add | New Project...". Find the "ASP.NET Empty Web Application" template and click OK. You will need this project to emulate the server that exposes data for your application.

  3. You now require an Entity Framework Data Model that represents data tables and views from the sample "Northwind" database. To add this Data Model, follow steps described in the How To: Generate Data Access Layer with Entity Framework Database First tutorial, starting from step two.
  4. After your Data Model is ready, you can proceed to adding a WCF Data Service that will establish a connection to the database and provide access to its data. Before you do so, go to Visual Studio's "Project | Manage NuGet Packages..." menu and install the WCF Data Services EntityFramework Provider package. This one allows you to use WCF Data Services with Entity Framework 6 and higher.

  5. In the Solution Explorer window, select your ASP.NET project and press "CTRL+SHIFT+A" to add a new item. Search for the "WCF Data Service" item, then click "Add".

  6. Open the .svc file added to your project and inspect its code. Notice that Visual Studio suggests you add the data source class name manually.

    Since your Data Model was generated with Entity Framework 6, the data service should inherit the EntityFrameworkDataService<Northwind2010Entities> class.

  7. You now have the server side ready, so add a blank WinForms project to your solution. Once the project is added, right-click it and select the "Set as StartUp Project" option.
  8. Right-click your project in the Solution Explorer window and choose the "Add Service Reference" menu item.

  9. In the "Add Service Reference" dialog that pops up, click the "Discover" button to browse for existing WCF Data Services. Make sure your service URL appears in the "Address" field, then click OK to finish.

Expanded What's Next?

Congratulations, you have created a sample Data Access Layer with data provided by a WCF Service! Check out other Data Access Layer tutorials or proceed to generating an application based on this layer.

Is this topic helpful?​​​​​​​