Entity Framework
Entity Framework in an ASP.NET is the enhancement of ADO.NET, which provides the strong mapping facilities. It is an ORM (Object Relational Mapping) framework, which gives the ability to the developers to work with various relational databases like SQL Server, Oracle, MYSQL, DB2 etc. and provide the automated mechanism for accessing & storing the data in the database.
There are the 3 approaches given below, which we use during an Application development.
- First, if you want to focus on your domain classes and subsequently create the database from your domain classes; it is called Code First Approach.
- Second, if you already have an existing database and create the domain classes from the database; it is called Database First Approach.
- Third, you want to design your database schema on Visual Designer, followed by creating the database and classes called Model First Approach.
Thus, in this article, we will learn how to develop a simple C# Application, using Entity Framework Code First approach.
Installation
Step 1
After downloading completely, click Install button and it will start the installation process.
Step 2
Once the installation process completes successfully, you will see the dialog given below. Close this dialog and restart your computer, if required.
Step 3
Once everything is done, you will see the main Window of Visual Studio.
Let’s create a new project from File → New → Project.
Go to other Project Types, select Visual Studio Solution and select Blank Soluton. Change solution name CodeFirstApproach, followed by clicking OK button.
Note:- One solution has multiple projects .
Right click on Solution Explorer and New Project and you can see below.
Select class library, followed by clicking OK.
Right click on the project in Solution Explorer and select Manage NuGet Packages.
This will open Manage NuGet packages dialogue box. Now, select Browse on top bar and search for an EntityFramework as shown below.
Select EntityFramework and click Install.