How to Create WCF Service in Visual Studio 2013

First open Visual Studio 2013. Create a new project and select WCF Service Application and give it the name WCFdemo.

wcf application service

Then click OK. Now In Solution Explorer right-click on the WCFdemo project and seelct Add New Item and seelct ADO.Net Entity Data Model.

ado dot net

Add a database here and select Tables.

employee table

Now your Solution Explorer looks like this.

wcf demo

Now add a new item, WCF Service.

new item

Select WCF Service and give it a name.

wcf service

Now EmployeeServices.svc and IEmployeeServices.cs files have been added to Solution Explorer.

IEmployeeServices

Now open the EmployeeServices.svc.cs file and write the following code.

code

Here Employee is my database table and m9codersEntities is the entity name.

Now open IEmployeeServices.cs and write the method name of the EmployeeServices.svc.cs file.

cs file

Now build the project. (Shortcut: F6).

Now run the EmployeeServices.svc file. (Ctrl+F5).

Then open the WCF Client popup window.

WCF Client popup window

And your service will be added.

Service Adding

After the service has been added successfully copy the URL and paste it into your browser.

Service added

You can see all your methods here and now can be used in any project.

In the next article, I will explain how to use a WCF service in MVC.

Up Next
    Ebook Download
    View all
    Learn
    View all