Click here to Skip to main content
Click here to Skip to main content

Implementing a WCF Service with Entity Framework (v4.5)

, 19 Mar 2014
Rate this:
Please Sign up or sign in to vote.
Implementing a simple WCF Service (GetProduct) to retrieve product information from the sample Northwind SQL server database with Entity Framework and LINQ to Entities.

Download source code WCFandEFSolution.zip - 2.4 MB

Previous Articles on .NET 4.0/Visual Studio 2010

In my previous articles on CodeProject.com, I have explained the fundamentals of Windows Communication Foundation (WCF), LINQ, LINQ to SQL, Entity Framework, and LINQ to Entities, including:

All above articles are based on .NET 4.0/Visual Studio 2010, so if .NET 4.0/Visual Studio 2010 are good for you, you can open and read any of above articles. For those who are learning WCF/LINQ/EF 4.5 with Visual Studio 2012, above articles are outdated. So from now on, I will update these articles with .NET 4.5/Visual Studio 2012.

New Articles on .NET 4.5/Visual Studio 2012

Following articles are updated ones with .NET 4.5/Visual Studio 2012. I will update the links when I have finished them.

  • Implementing a Basic Hello World WCF Service (v4.5)
  • Implementing a WCF Service with Entity Framework (v4.5) -- this article
  • Concurrency Control of a WCF Service with Entity Framework (v4.5) -- next article
  • Introducing LINQ—Language Integrated Query (v4.5)
  • LINQ to SQL: Basic Concepts and Features (v4.5)
  • LINQ to SQL: Advanced Concepts and Features (v4.5)
  • LINQ to Entities: Basic Concepts and Features (v4.5)

Introduction

In a previous article (Implementing a Basic Hello World WCF Service (v4.5)), we have learned how to create a basic WCF Service manually from scratch. In that article, we also manually created a host application, generated the proxy and configuration files, and created a test client to test the WCF Service. You can review that article to learn what a WCF Service is really like under the hood.

Now in this article, we will implement a simple WCF Service using a built-in Visual Studio WCF template. This simple WCF Service will have only one operation, GetProduct. This operation will accept an integer input as the product ID, and connect to a backend database to retrieve the product details for the specified product ID using LINQ to Entities. The Microsoft sample database Northwind will be used for the backend database, and Visual Studio 2012 will be used as the IDE.

In a future article (Concurrency Control of a WCF Service with Entity Framework (v4.5)), we will implement another operation, UpdateProduct, to update a product in the database through the Entity Framework. We will cover concurrency control in that article, and we will create a WPF test client in that article to test the UpdateProduct operation with concurrency support.

In this article, we will build the solution in the following order:

  • Create the WCF Service
    • Create a new solution and project using a WCF template
    • Create the service interface
      • Create the operation contract
      • Create the data contract
    • Implement the service interface
    • Modify the app.config file
    • Test the service using the WCF Test Client
  • Apply LINQ to Entities to the WCF Service
    • Prepare the database
    • Model the Northwind database
    • Rename the EF Product class
    • Retrieve product details from the database using EF
    • Translate the ProductEntity object to a Product object
    • Test the WCF Service with EF
    • Test exceptions

Creating the WCF Service

In the first half of this article, we will create the simple WCF Service. This WCF Service will contain the GetProduct operation, which will return a product object to the client. The product detail is hard coded in this WCF Service, except the ID will be the input from the client. Later in this article, we will enhance this WCF Service to use LINQ to Entities to retrieve the real product detail from a real backend database.

Creating a new solution and project using WCF templates

We need to create a new solution for this article, and add a new WCF project to this solution. There are a few built-in WCF service templates within Visual Studio 2012. In this article, we will use the service library template to create the WCF Service.

Follow these steps to create the WCF and EF solution and the project using the service library template:

1. Start Visual Studio 2012, select the menu option File | New | Project..., and you will see the New Project dialog box.

2. In the New Project window, specify Visual C# | WCF | WCF Service Library as the project template, WCFandEFService as the (project) name, and WCFandEFSolution as the solution name. Make sure that the Create directory for solution checkbox is selected.

3. Click the OK button, and the solution is created with a WCF project inside it. The project already has a IService1.cs file to define a service interface, and Service1.cs to implement the service. It also has an app.config file, which we will cover shortly.

Now we have created the WCF Service project using the C# WCF Service Library template. This project is actually an application containing a sample WCF Service, a hosting application (WcfSvcHost), and a WCF Test Client. This means now we can use the built-in WCF Test Client to invoke the sample WCF Service.

To try it, just press Ctrl+F5, and you will see the WCF Test Client is up and running! Double click the GetData operation in the left panel, enter a number in the Value textbox in the right panel, then click the button Invoke, and you will see the WCF Service has been invoked: the response of the WCF Service is now displayed in the bottom part of the right panel.

Note: in order to run the WCF Test Client, you have to log in to your machine as a local administrator. You may also need to run Visual Studio as an administrator. We will discuss more about the WCF Test Client later.

Creating the service interface

In the previous section, we created a WCF project using the WCF Service Library template. In this section, we will create the service interface contracts.

Because two sample files have already been created for us, we will try to re-use them as much as possible. Then, we will start customizing these two files to create the service contracts.

Creating the operation contract

To create the service operation contract, we need to open the IService1.cs file and do the following:

1. Change the file's name from IService1.cs to IProductService.cs.

2. Change the interface name from IService1 to IProductService, if it has not been done for you.

3. Change the first operation contract definition from this line:

string GetData(int value);

to this line:

Product GetProduct(int id);

4. Delete the operation GetDataUsingDataContract.

With these changes, we have defined a service contract. It is used to get the product details for a specific product ID. The product type, which we used to define the service contract, is still not defined. We will define it right after this section.

The content of the service interface for IProductService should look like this now:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFandEFService
{
    [ServiceContract]
    public interface IProductService
    {
        [OperationContract]
        Product GetProduct(int id);
    }
    // original code for CompositeType
}

Note: this is not the whole content of the IProductService.cs file. The bottom part of this file now should still have the class CompositeType, which we will change to our Product type in the next section.

Creating the data contract

Another important aspect of SOA design is that you shouldn't assume that the consuming application supports a complex object model. A part of the service boundary definition is the data contract definition for the complex types that will be passed as operation parameters or return values.

For maximum interoperability and alignment with SOA principles, you should not pass any .NET specific types such as DataSet or Exceptions across the service boundary. You should stick to fairly simple data structure objects such as classes with properties, and backing member fields. You can pass objects that have nested complex types such as 'Customer with an Order collection'. However, you shouldn't make any assumption about the consumer being able to support object-oriented constructs such as inheritance, or base-classes for interoperable Web Services.

In our example, we will create a complex data type to represent a product object. This data contract will have five properties: ProductID, ProductName, QuantityPerUnit, UnitPrice, and Discontinued. These will be used to communicate with client applications. For example, a supplier may call the Web Service to update the price of a particular product, or to mark a product for discontinuation.

It is preferable to put data contracts in separate files within a separate assembly, but to simplify our example, we will put the DataContract within the same file as the service contract. So, we will modify the file IProductService.cs as follows:

1. Delete the DataContract CompositeType.

2. Add a new DataContract Product with following 5 properties:
ProductID, ProductName, QuantityPerUnit, UnitPrice, Discontinued.

The final content of the file IProductService.cs should be like this now:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFandEFService
{
    [ServiceContract]
    public interface IProductService
    {
        [OperationContract]
        Product GetProduct(int id);
 
    }

    [DataContract]
    public class Product
    {
        [DataMember]
        public int ProductID { get; set; }
        [DataMember]
        public string ProductName { get; set; }
        [DataMember]
        public string QuantityPerUnit { get; set; }
        [DataMember]
        public decimal UnitPrice { get; set; }
        [DataMember]
        public bool Discontinued { get; set; }
    }
}

Implementing the service interface


To implement the service interface that we defined in the previous section, open the Service1.cs file and do the following:

1. Change the file's name from Service1.cs to ProductService.cs.

2. Change the class name from Service1 to ProductService, if it has not been done for you. And make it inherit from the IProductService interface, instead of IService1, if this has not been refactored for you. The class definition line should be like this:

public class ProductService : IProductService

3. Delete the GetData and GetDataUsingDataContract methods.

4. Add the following method, to get a product:

public Product GetProduct(int id)
{
    // TODO: retrieve the real product info from DB using EF
    Product product = new Product();
    product.ProductID = id;
    product.ProductName = "fake product name";
    product.UnitPrice = (decimal)10.0;
    return product;
}
 

In this method, we created a fake product and returned it to the client. Later, we will remove the hard-coded product from this method and retrieve the real product info from the database using EF.

The contents of the ProductService.cs file should be like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFandEFService
{
    public class ProductService : IProductService
    {
        public Product GetProduct(int id)
        {
            // TODO: retrieve the real product info from DB using EF
            Product product = new Product();
            product.ProductID = id;
            product.ProductName = "fake product name";
            product.UnitPrice = (decimal)10.0;
            return product;
        }
    }
}

Modifying the app.config file

Because we have changed the service name, we have to make the appropriate changes to the configuration file. Note: when you rename the service, if you have used the refactor feature of Visual Studio, some of the following tasks may have been done by Visual Studio.

Follow these steps to change the configuration file:

1. Open the app.config file from Solution Explorer.

2. Change all instances of Service1 to ProductService.

The content of the app.config file should now look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WCFandEFService.ProductService">
        <endpoint address="" binding="basicHttpBinding" contract="WCFandEFService.IProductService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFandEFService/ProductService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
 

Testing the service using the WCF Test Client

Because we are using the WCF Service Library template in this example, we are now ready to test this Web Service. As we pointed out when creating this project, this service will be hosted in the Visual Studio 2012 WCF Service Host environment.

To start the service, press F5 or Ctrl+F5. WcfSvcHost will be started and the WCF Test Client is also started. This is a Visual Studio 2012 built-in test client for WCF Service Library projects.

Note: in order to run the WCF Test Client, you have to log in to your machine as a local administrator. You also have to start Visual Studio as an administrator if you have changed the port from the default value to some other port, like 8080. Otherwise, you may get an "Access is denied" error.

Now, from this WCF Test Client, we can test our simple GetProduct operation.

1. In the left panel of the client, double-click on the GetProduct operation; the GetProduct Request will be shown on the right-side panel.

2. In this Request panel, specify an integer for the product ID, and click the Invoke button to let the client call the service. You may get a dialog box to warn you about the security of sending information over the network. Click the OK button to acknowledge this warning (you can check the 'In the future, do not show this message' option, so that it won't be displayed again).

Now, the message Invoking Service... will be displayed in the status bar, as the client is trying to connect to the server. It may take a while for this initial connection to be made, as several things need to be done in the background. Once the connection has been established, a channel will be created and the client will call the service to perform the requested operation. Once the operation has completed on the server side, the response package will be sent back to the client, and the WCF Test Client will display this response in the right bottom panel.

If you have started the test client in debugging mode (by pressing F5), you can set a breakpoint at a line inside the GetProduct method in the ProductService.cs file, and when the Invoke button is clicked, the breakpoint will be hit so that you can debug the service as you usually do with any other .NET application.

Note that the response is always the same, no matter what product ID you use to retrieve the product (except the product ID field). Specifically, the product name is hard-coded, as shown in the diagram. Moreover, from the client response panel, we can see that several properties of the Product object have been assigned default values.

The Request/Response packages are displayed in grids by default, but you have the option of displaying them in XML format. Just select the XML tab from the bottom of the right-hand side panel, and you will see the XML formatted Request/Response packages. From these XML strings, you will discover that they are SOAP messages.

Besides testing operations, you can also look at the configuration settings of the Web Service. Just double-click on Config File from the left-side panel and the configuration file will be displayed in the right-side panel. This will show you the bindings for the service, the addresses of the service, and the contract for the service.

Note: what you see here for the configuration file is not an exact image of the actual configuration file. It hides some information, such as debugging mode and service behavior, and includes some additional information on reliable sessions and compression mode.

If you are satisfied with the test results, just close the WCF Test Client, and you will go back to the Visual Studio IDE. Note that as soon as you close the client, the WCF Service Host is stopped. This is different from hosting a WCF service inside the IIS Express / ASP.NET Development Server, where after you close the client, the hosting Server still stays active.

Applying LINQ to Entities to the WCF Service

In previous sections, we have created a simple WCF Service to get production details for an input product ID. The production details are hard coded in the service implementation.

In the following sections, we will apply LINQ to Entities to the WCF Service. We will connect to a database through Entity Framework, and retrieve the real product information from the database.

Preparing the database

In this article, we will use the Microsoft sample database, Northwind, as the backend database. This database is not installed by default in SQL Server 2005 or SQL Server 2008, so first, we need to install it to our database server.

1. Download the database package.

Just search for "Northwind Sample Databases download" on the Internet, or go to this page: http://www.microsoft.com/en-us/download/details.aspx?id=23654 and download the file SQL2000SampleDb.msi. Note: this sample database was designed for SQL Server 2000, but it can also be used in SQL Server 2005 and SQL Server 2008.

2. Install (extract) it to: C:\SQL Server 2000 Sample Databases.

3. Change the security of both Northwnd.mdf and Northwnd.ldf to be read/write-able to your SQL Server service account user (or just give Everyone full access).

4.. Open SQL Server 2005/2008 Management Studio.

5. Connect to your database engine.

6. Right click on the Databases node, and select Attach... from the context menu, as shown in the SQL Server Management Studio diagram below:

7. In the pop-up Attach Databases dialog box, click Add, browse to the file C:\SQL Server 2000 Sample Databases\NORTHWND.MDF, click OK, and you now have the Northwind database attached to your SQL Server 2005 or 2008 engine.

Note: if you have a SQL Server 2012 database, you cannot attach it as shown above. You have to create the database by yourself. You can follow these steps to create it:

1. Create a new empty database called Northwind.

2. Open the sample database script file instnwnd.sql. This script file should be inside your sample database folder (C:\SQL Server 2000 Sample Databases).

3. Delete the following two lines from the instnwnd.sql script:

exec sp_dboption 'Northwind','trunc. log on chkpt.','true'

exec sp_dboption 'Northwind','select into/bulkcopy','true'

4. Replace the deleted lines with following line:

ALTER DATABASE Northwind SET RECOVERY SIMPLE

Now run the entire (modified) script in your empty Northwind database in SQL Server 2012 Management Studio. This will create the entire database, including the test data, in your SQL Server 2012 database.

Modeling the Northwind database

Now we have the database ready, we can model this database using Entity Framework. After we have the database modeled, we will use LINQ to Entities to retrieve the real product information from the database.

You can follow these steps to add an Entity data model to the project.

1. In Solution Explorer, right-click on the project item WCFandEFService, select menu option Add | New Item..., and then choose Visual C# Items | ADO.NET Entity Data Model as the Template, and enter Northwind.edmx as the name.

2. Clicking the Add button will bring you to the Entity Data Model Wizard. In this wizard, select "Generate from database", click the Next button, and the connection dialog window will pop up. Enter your database server name, like localhost, specify the logon details, and choose Northwind as the database, then click the OK button to close this window.

3. From the Entity Data Model Wizard, click button Next to go to the "Choose Your Database Objects" screen. Select the Products table, and click the Finish button to close the wizard.

This will generate the db context file and the Product class file. You can open them in the solution explorer to examine their contents.

Renaming the EF Product class

If you compile the project now, you will see an error "Missing partial modifier on declaration of type 'WCFandEFService.Product'; another partial declaration of this type exists". This is because earlier in this article, we have created our own Product class for the service data contract, but now another Product class was created by the Entity Framework. Both are within the same namespace, thus there is a conflict

There are two ways to solve this problem. First, we can remove our own Product class definition, and expose the EF Product class as the WCF service data contract class. In this way, we can work on only one Product entity class through the whole project, and avoid some duplication of entity definitions. Actually Microsoft has two similar approaches, one is using POCO entities and another one is using self-tracking entities. However both approaches are not recommended by Microsoft, so we are not going to take any of these approaches in this article.

Another way is to separate our own Product class from the EF Product class, making them two different classes. In this way our own Product class will serve as the WCF data contract class, and the EF Product class will serve as the ORM data entity class. Now we have a clear separation of concerns, and the outside world will never know what kind of ORM we are using underneath. I like this idea, so in this article, we will go this way.

We have a few options to keep our own Product class and the EF Product class inside the same project. First, we can add a data access layer to the WCF Service solution, limit the EF classes within the data access layer, and limit our own Product class within the service interface layer. Actually, this is the preferred way to develop an enterprise WCF Service, just as I discussed in my book WCF 4.5 Multi-Layer Services Development with Entity Framework (you can find more information about this book at the end of this article). But in this article, we will have only one layer for the WCF Service to keep it easy and simple, so we won't take this approach. A second way is to put the EF entity classes in a separate namespace, so two Product classes can co-exist without a problem. But having two Product classes in the same project is confusing, even if they are in two different namespaces. So we will go the third way, that is, renaming the EF Product entity class to ProductEntity.

To rename the EF Product class, open the file Northwind.edmx, click on the class name, and rename it. The renamed model should be like this:

After you rename the EF Product class, if you re-build the service, you should see no errors.

Retrieving product details from the database using EF

Now, inside the GetProduct method, we can use the following statements to get the product details from the database using LINQ to Entities:

using (var context = new NorthwindEntities())
{
    var productEntity = (from p
                            in context.ProductEntities
                            where p.ProductID == id
                            select p).FirstOrDefault();
}

Here, we first created a DbContext object for the EF model, then we used the LINQ to Entities statement to get the product entities from the database for the given ID. Because the return result of the LINQ to Entities statement is IQueryable, we called the FirstOrDefault method to get only the first record. This method also gives a null result if the query doesn't yield any result from the database.

Translating the ProductEntity object to a Product object

However, we cannot return this product object back to the caller, because this product is of type ProductEntity, which is not the type that the caller is expecting. The caller is expecting a return value of type Product, which is a data contract defined within the service interface. We need to translate this ProductEntity object to a Product object. To do this, we add the following new method to the ProductService class:

private Product TranslateProductEntityToProduct(
                ProductEntity productEntity)
{
    Product product = new Product();
    product.ProductID = productEntity.ProductID;
    product.ProductName = productEntity.ProductName;
    product.QuantityPerUnit = productEntity.QuantityPerUnit;
    product.UnitPrice = (decimal)productEntity.UnitPrice;
    product.Discontinued = productEntity.Discontinued;
    return product;
}

Inside this translation method, we copy all of the properties from the ProductEntity object to the service contract data object, but not the last three properties - UnitsInStock, UnitsOnOrder, and ReorderLevel. We assume these three properties are used only inside the service implementations. Outside callers cannot see them at all.

The GetProduct method should now look like this:

public Product GetProduct(int id)
{
    Product product = null;
    using (var context = new NorthwindEntities())
    {
        var productEntity = (from p
                                in context.ProductEntities
                                where p.ProductID == id
                                select p).FirstOrDefault();
        if (productEntity != null)
            product = TranslateProductEntityToProduct(productEntity);
        else
            throw new Exception(string.Format("Invalid product id {0}", id));
    }
    return product;
}

Note: inside the GetProduct method, after we retrieve the product details from the database using EF, we first test the object to see if it is null. If so, we know the input ID is not a valid product ID in our database. We then throw an exception to tell the client. However, in a real WCF Service, you shouldn't throw any exceptions to the client; instead, you should define and throw a Fault to the client. Again, more information about Faults can be found in my WCF and Entity book.

The final contents of the ProductService.cs file should be like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFandEFService
{
    public class ProductService : IProductService
    {
        public Product GetProduct(int id)
        {
            // code before using EF
            /* 
            Product product = new Product();
            product.ProductID = id;
            product.ProductName = "fake product name";
            product.UnitPrice = (decimal)10.0;
            return product;
            */

            Product product = null;
            using (var context = new NorthwindEntities())
            {
                var productEntity = (from p
                                        in context.ProductEntities
                                        where p.ProductID == id
                                        select p).FirstOrDefault();
                if (productEntity != null)
                    product = TranslateProductEntityToProduct(productEntity);
                else
                    throw new Exception(string.Format("Invalid product id {0}", id));
            }
            return product;
        }

        private Product TranslateProductEntityToProduct(
                ProductEntity productEntity)
        {
            Product product = new Product();
            product.ProductID = productEntity.ProductID;
            product.ProductName = productEntity.ProductName;
            product.QuantityPerUnit = productEntity.QuantityPerUnit;
            product.UnitPrice = (decimal)productEntity.UnitPrice;
            product.Discontinued = productEntity.Discontinued;
            return product;
        }
    }
}

Testing the WCF Service with EF

We can now compile and test the new service with EF support. We will still use the WCF Test Client to simplify the process.

1. Start the WCF Service Host application and WCF Service Test Client, by pressing F5 or Ctrl+F5.

2. In the WCF Service Test Client, double-click on the GetProduct operation, to bring up the GetProduct test screen.

3. Enter a value of 56 for the ID field, and then click the Invoke button.

You will see that this time the product is returned from the real database, instead of hard coded. Also, note that the UnitsOnOrder property is not displayed as it is not part of the service contract data type.

If you see an exception instead of following screen, go to next section to find out why and how to fix it.

Testing exceptions

Now, enter an invalid product ID, like 0, and you will get this error message:

This is because inside the WCF Service, we couldn't find the product in the Northwind database with ID 0, so we threw an exception for it. Because we haven't turned on the includeExceptionDetailInFaults flag in the app.config, the client application couldn't get the exception details.

To display the exception details, you can open the app.config file, change the value of includeExceptionDetailInFaults from False to True, and try again. This time, you will get this error message:

This time, the exception detail is returned back to the client application, as you can see; however, this is not recommended. The reason is, not all clients can understand a .NET exception. It will be treated as an unknown fault by certain types of clients. To make it understandable by all kinds of clients, we need to define and throw a fault when we can't get the product from the database for the given ID. Another reason that this is not recommended is, the raw C# exception will reveal the implementation details of the service, such as the language used, the platform of the service, and the stack details. This may pose some security concerns to your service.

If the product id you have entered is a valid one, but you still get an exception, like in following image:

This means your EDM (Entity Data Model) has not been added correctly. You can remove your EDM, re-add it, or just add this section to your app.config file:

<connectionStrings>
  <add name="NorthwindEntities" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=Northwind;user id=sa;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

Make sure this whole section is a child node of the root configuration node, and adjust it according to your database environment.

Summary

In this article, we have created a simple WCF Service that retrieves product details from a sample database using Entity Framework. The key points in this article include:

  • WCF Services should have explicit boundaries
  • The WCF Service Library template can be used to create WCF Services that will be hosted by the WCF Service Host, and these can be tested using the WCF Service Test Client
  • Entity Framework can be used to model backend databases
  • Entity Framework entities represent the internal data of the service and they should not be exposed to clients
  • LINQ to Entities can be used to query databases using EF
  • Fault contracts should be used when there are exceptions

Note: this article is based on chapter 5 and chapter 9 of my book "WCF 4.5 Multi-Layer Services Development with Entity Framework (Third Edition)" (ISBN: 1849687668 ISBN 13: 9781849687669). This book is a hands-on guide to learn how to build SOA applications on the Microsoft platform using WCF and Entity Framework. It is updated for VS2012 from my previous book: WCF 4.0 Multi-tier Services Development with LINQ to Entities.

With this book, you can learn how to master WCF, LINQ, Entity Framework and LINQ to Entities concepts by completing practical examples and applying them to your real-world assignments. It is ideal for beginners who want to learn how to build scalable, powerful, easy-to-maintain WCF Services. This book is rich with example code, clear explanations, interesting examples, and practical advice. It is a truly hands-on book for C++ and C# developers.

You don't need to have any experience in WCF, LINQ, Entity Framework or LINQ to Entities to read this book. Detailed instructions and precise screenshots will guide you through the whole process of exploring the new worlds of WCF, LINQ, Entity Framework and LINQ to Entities. This book is distinguished from other WCF, LINQ, Entity Framework and LINQ to Entities books by that, this book focuses on how to do it, not why to do it in such a way, so you won't be overwhelmed by tons of information about WCF, LINQ, Entity Framework and LINQ to Entities. Once you have finished this book, you will be proud that you have been working with WCF, LINQ, Entity Framework and LINQ to Entities in the most straightforward way.

You can buy this book from Amazon, or from the publisher's website at http://www.packtpub.com/windows-communication-foundation-4-5-multi-layer-services-development-framework/book.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mike_Liu
Software Developer (Senior)
United States United States
Mike is a senior software engineer at an investment management firm, and a faculty member at Brandeis University, teaching Windows Communication Foundation programming with C#. He is a Microsoft Certified Solution Developer and a Sun Certified Java Programmer. He has authored a few books for Unix C/C++, C#, WCF and LINQ. Mike has deep expertise in software development with WCF, WPF, ASP.NET, MVC, BPMS, JavaScript, and SQL Server. He has been a key developer, architect and project lead for many software products in various industries, such as statistical data reporting, telecommunication, resource control, call center, student loan processing, and investment management.

Comments and Discussions

 
SuggestionGenerate DataContract via T4 PinmemberThang Believe27-Apr-14 4:34 
QuestionDear Mike, PinprofessionalAnupam Singh_18-Apr-14 19:43 
GeneralMy vote of 3 PinprofessionalAnupam Singh_18-Apr-14 19:41 
QuestionWCF Service Library Pinmemberdarrenrhymer27-Mar-14 4:00 
QuestionSome questions PinprofessionalBELGIUMsky27-Mar-14 0:27 
QuestionGood article PinmemberMember 768997824-Mar-14 15:26 
QuestionExecuting stored procedure Pinmemberfredatcodeproject19-Mar-14 1:30 
AnswerRe: Executing stored procedure PinpremiumMike_Liu19-Mar-14 5:27 
GeneralRe: Executing stored procedure Pinmemberfredatcodeproject19-Mar-14 12:01 
Questionalmost Pinmemberitrywhatic#6-Mar-14 11:02 
AnswerRe: almost PinpremiumMike_Liu19-Mar-14 5:23 
QuestionImplementing WCF Service without Entity Framework PinmemberMember 89843309-Feb-14 5:23 
QuestionNorthWind db in SQL Server 2012 PinmemberMember 1049681231-Dec-13 8:39 
AnswerRe: NorthWind db in SQL Server 2012 PinpremiumMike_Liu18-Mar-14 9:49 
QuestionHow is this different than POCO? PinmemberMember 44837227-Nov-13 8:08 
QuestionGreatWork PinmemberSaif8419-May-13 4:39 
AnswerRe: GreatWork PinmemberMike_Liu20-May-13 5:59 
GeneralRe: GreatWork PinmemberSaif8421-May-13 9:57 
GeneralRe: GreatWork PinmemberMike_Liu21-May-13 11:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 19 Mar 2014
Article Copyright 2013 by Mike_Liu
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid