ASP.NET MVC

CRUD Operations in Database-First Approach With ASP.NET MVC Framework Part-1

Here, we will learn about using DB First approach in ASP.NET MVC with entity framework. In DB first approach, Database is created first and from the database, POCO classes are generated automatically by Entity framework.

Firstly we will create the database in SQL Server.

Create the database

Enter the database name

Create the table.

Enter the table fields and make Id column as Identity

Enter the table name

Open Visual Studio and create a new project.

Enter the project name and select ASP.NET Web Application

Choose MVC as a framework

Now we have to Install the Entity Framework for performing database related operations. So open the Package manager console.

Write the command in the console

Install-Package EntityFramework

Add the ADO.NET Entity Data Model into the Models folder.

Choose Data from Left Menu and choose ADO.NET Entity Data Model and give it a name.

Choose EF Designer From Database and Click next.

Select the Server and authentication types and database

Test the connection as it properly has done or not.

Enter the Model name if you have to change.

Choose the object you want to include in EDMX file.

You will see the .edmx file

Now your connection will be registered with your web application and you can see the connection string in Web.Config file present at the root folder.

You will see that the Model is generated in the Models folder.

Further, we will continue in Part-2

Faisal Pathan

Faisal Pathan is a founder of TheCodeHubs, .NET Project Manager/Team Leader, and C# Corner MVP. He has extensive experience with designing and developing enterprise-scale applications. He has good skills in ASP.NET C#, ASP.NET Core, ASP.NET MVC, AngularJS, Angular, React, NodeJS, Amazon S3, Web API, EPPlus, Amazon MWS, eBay Integration, SQL, Entity Framework, JavaScript, eCommerce Integration like Walmart, Tanga, Newegg, Group-on Store, etc. and Windows services.

View Comments

  • Good post but I was wanting to know if you could write a litte more on this subject? I'd be very thankful if you could elaborate a little bit more. Thanks!

  • I do not even know how I ended up here, but I thought this post was good. I do not know who you are but certainly you're going to a famous blogger if you are not already ;) Cheers!

Share
Published by
Faisal Pathan

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago