Consuming WCF in ASP.NET MVC 5 with Entity Framework 6 using Visual Studio 2017
This article includes a step by step tutorial on how to create a WCF Service and a consumer application ASP.NET MVC 5. We will be using Entity Framework for database operations.
- WCF – Windows Communication Foundation is a framework for building service-oriented applications. It allows different applications to interact with each other via a service provider.
- MVC – Model-View-Controller – a design pattern for successfully and efficiently relating the user interface to underlying data models.
- Entity Framework – is an open source object-relational mapping framework.
- Create a blank solution in Visual Studio, name it MoviesApp
- Create a WCF Application
- Right click on the MoviesApp on the Solution Explorer then go to Add -> New Project.
- Select WCF Service Application then name it WCF. Click Ok
- After the project is successfully created, we now add reference to 3 DLL files from the MySQL Connector directory:
Go to the Solution Explorer then right click on Reference then click Add Reference. Refer to the screenshot bellow:
- A window will pop-up. The the left side pain, click on “Browse” then locate the 3 DLL files as seen from the
screenshot bellow. The path to the DLL files is: C:\Program Files (x86)\MySQL\Connector NET 8.0\Assemblies\v4.5.2. When you’re done finding the files, make sure to check all 3 files before clicking the “OK” button.
- Install Entity Framework to the project using Nuget Package manager. Follow the screenshot bellow:
- On the Nuget Package Manager window, click on “Browse” then search for “entity framework”. Select EntityFramework from the results then on the right side pain check the box of your application then click on the “Install” button. Refer to the screenshot bellow:
- Open MySQL Workbench then create a new schema, name it anything you want. Then inside the schema create a new table called “movies” with the following columns:
Do you need help with a project? or have a new project in mind that you need help with?Contact Me