In this article I will explain a step by step tutorial, how to configure Entity Framework in Windows Forms (WinForms) Application.
This article will illustrate, how to configure Entity Framework and connect it to SQL Server database.
Note: For more details on how to use Entity Framework for populating DataGridView in Windows Forms Application, please refer my article Populate (Bind) DataGridView using Entity Framework in Windows Forms Application using C# and VB.Net.
 
 

Database

Here I am making use of Microsoft’s Northwind Database. You can download it from here.
 
 

Configuring and connecting Entity Framework to database

Following are the steps for configuring Entity Framework and connecting to SQL Server database.
1. You will need to add Entity Data Model to your project by right clicking the Solution Explorer and then click on Add and then New Item option of the Context Menu.
Configure Entity Framework Step By Step in ASP.Net
 
2. From the Add New Item dialog window, select ADO.NET Entity Data Model and give a suitable Name and click on Add.
Configure Entity Framework Step By Step in ASP.Net
 
3. Then, from the Entity Data Model Wizard select EF Designer from database option.
Configure Entity Framework Step By Step in ASP.Net
 
4. Now the wizard will ask you to connect and configure the Connection String to the database. Here click on New Connection.
Configure Entity Framework Step By Step in ASP.Net
 
5. Then, from the Connection Properties dialog window, you will need to select the
1.     SQL Server Instance
2.     Database
And then click Test Connection to make sure all settings are correct.
Configure Entity Framework Step By Step in ASP.Net
 
6. Once the Connection String is generated, select the Yes, include the sensitive data in the connection string RadioButton and click on Next.
Configure Entity Framework Step By Step in ASP.Net
 
7. Next you will need to choose the Entity Framework to be used for connection.
Configure Entity Framework Step By Step in ASP.Net
 
8. Now you will need to choose the Tables that you need to connect and work with Entity Framework. Here Customers Table is selected.
Configure Entity Framework Step By Step in ASP.Net
 
9. The above was the last step and now, the Entity Data Model is ready with the Customers Table of the Northwind database.
Configure Entity Framework Step By Step in ASP.Net