Tuesday, September 1, 2015

How to set up ADO.net Entity Framework project or website in asp.net

In this article I am going to explain how to set up a ADO.Net Entity Framework project or website in asp.net using Visual studio 2013

Description:

In this tutorial I am going to set up a project/website using database first approach. I already created a database.

Implementation:
To set up an ADO.net project/website follow the below given steps:

Step 1: Create a website/project
First of all create a website or project.

Step 2:
Now right click on website in solution explore. Go to Add >> Add new item.

How to set up ADO.net Entity Framework project or website in asp.net


Add new item window will be open and select the ADO.NET Entity data model. After that click on add button.

How to set up ADO.net Entity Framework project or website in asp.net

Now you get a pop up message to place the .edmx file in the App_Code folder. Click on Yes button. It will add an App_Code folder to project/website.

How to set up ADO.net Entity Framework project or website in asp.net

Step 3: Entity data model wizard
Now you see Entity data model wizard will be open.  Select the Generate from database option and click on next button.

How to set up ADO.net Entity Framework project or website in asp.net

In next step we choose the data connection. Here I am going to create a new data connection. Click on new connection button and connection properties window will be open.

How to set up ADO.net Entity Framework project or website in asp.net

Choose the server name and after that select the database. We can check the connection establish or not via click on Test connection button. If connection is succeed then click on OK button. 
How to set up ADO.net Entity Framework project or website in asp.net



When we click on OK button we again back to connection window that showing the database name which we select and entity name that set in web.config file. We can change the entity connection name. 

How to set up ADO.net Entity Framework project or website in asp.net

After done click on next button.

Step 4: Choose the Entity framework version
In this step choose the preferred entity framework version. I am using the entity framework 6.0. And click on Next button.

How to set up ADO.net Entity Framework project or website in asp.net

Step 5: Choose the database objects and settings
In this step choose the database object i.e. Tables, views and store procedures and Function that you want to use.  We can choose all the options or a particular option.

How to set up ADO.net Entity Framework project or website in asp.net

Click on finish button.

You have done it. Now you see in solutions explore of website there is Model.Context.tt , Model.edmx and Model.tt file in App_Code folder.


How to set up ADO.net Entity Framework project or website in asp.net

  In this article we have learn to how to set up ADO.NET Entity Framework project or website in asp.net using Visual studio 2013I hope you enjoyed this article.

No comments:

Post a Comment