In this article, we will implement CRUD (Create, Retrieve, Update, Delete) operations using ASP.NET MVC Core application with Entity Framework Core. We will take “Product” entity as reference for implementation purpose. In our previous ASP.NET Core Tutorial, we have discussed in details about the basics concepts and details related to ASP.NET Core including primary features, ASP.NET Core Initialization Process, Configuration Model, ASP.NET Core Middle-ware, Routing in ASP.NET Core and more. We strongly recommend to go through it for better understanding.
Below are the Prerequisites for understanding and executing the ASP.NET Core application.
- Microsoft Visual Studio 2015.
- VS 2015 Tooling Preview 2 - .NET Core 1.0.0 (https://go.microsoft.com/fwlink/?LinkID=827546)

Entity Framework in Depth: The Complete Guide
Connect your applications to a SQL Server database. Understand the differences between code-first and database-first workflows….
Build a Real-world App with ASP.NET Core and Angular 2 (4+)ASP.NET Core and Angular 2(4+) is an ideal combination for building real world modular and cloud-optimized applications.
Lets start to perform CRUD Operations in this ASP.NET core Tutorial
Below steps guide you to creating a new project.
- Open and start Visual Studio 2015.
- Click on File -> New -> Project.

- Click on “OK”.
Select “Empty” template and Click on “OK”. - The new empty solution will be open in your window.

- The Solution Explorer window for that project is defined as belows:

- For running the application, you first need to change the database connection string. Open “appsettings.json” file.
You need to be change the connection string as per your system. - In Package Manager Console, type “Update-Database”. This command creating a new database in your system as per your connection string.
- Database snapshot is as below:

- Right click on solution, and Rebuild the solution.
- We have move forward to understand creation of Entity, its’ snapshot, Listing page, Creation page, Editing page and Deleting a record in below section.
“Product” Entity Section:
Startup and configuration file Section:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849501. Product.cs classusing System;namespace DotNetCoreApplication.DbEntities{public class Product{public long Id { get; set; }public string Name { get; set; }public string Code { get; set; }public string ProductCategory { get; set; }public DateTime? CreatedDate { get; set; }public DateTime? ModifiedDate { get; set; }}}2. ProductMap.cs classDefining primary key as bellowsusing Microsoft.EntityFrameworkCore.Metadata.Builders;namespace DotNetCoreApplication.DbEntities{public class ProductMap{public ProductMap(EntityTypeBuilder<Product> entityBuilder){entityBuilder.HasKey(t => t.Id);entityBuilder.Property(t => t.Name).IsRequired();entityBuilder.Property(t => t.Code).IsRequired();entityBuilder.Property(t => t.ProductCategory).IsRequired();}}}3. Defining Entity Framework Context classusing Microsoft.EntityFrameworkCore;namespace DotNetCoreApplication.DbEntities{public class EFContext:DbContext{public EFContext(DbContextOptions<EFContext> options) : base(options){}protected override void OnModelCreating(ModelBuilder modelBuilder){base.OnModelCreating(modelBuilder);new ProductMap(modelBuilder.Entity<Product>());}}}
Listing Screen Section
1. Cshtml Page:
2. Controller Action Method:
3. Output screen:

Creation/Modifying Section:
1. Cshtml page
2. Create/Edit Controller Action Methods
3. Output screen

Delete Section:
1. Cshtml Page
2. Delete Controller Action Methods
3. Output screen
This ASP.NET Core Tutorial can be taken as a first step towards creating a professional application using ASP.NET Core with Entity Framework using C#.

- Build a full-stack web app with ASP.NET Core, Entity Framework Core and Angular 2 & 4.
- Implement a Clean & Decouple Architecture.
- Properly implement the repository and unit of work patterns.
- Troubleshoot common runtime errors.
- Test APIs using PostMan.
- Integrate ASP.NET MVC/Core with Angularjs.
- Understand and apply the Dependency Inversion Principle (DIP).
- Use the new dependency injection feature in ASP.NET Core.
- Build APIs with ASP.NET Core
- and more….
- ASP.NET Web API 2 Hands-On
- ASP.NET Web Forms - Beginners to Professional
- All about ASP.NET MVC
- Practical Guide to ASP.NET Web API
- Learn Entity Framework Core 2.0 (EFC2) using ASP.Net Core





