Note: See CRUD operations application for
ASP.NET MVC 5 and Entity Framework 6.
A Visual Studio 2015 project which shows how to use the Entity Framework Core in an ASP.NET Core web application project, using the Code First development approach.
The code illustrates the following topics:
- Listings, create, update and delete operations.
- Create, Update and Delete operations perform in bootstrap modal pop up.
- Database design using entity framework code first approach with fluent API.
- Bundling and Minification for CSS.
- Dependency Injection for DbContext.
To build and run this sample as-is, you must have Visual Studio 2015 installed. In most cases you can run the application by following these steps:
- Download and extract the .zip file.
- Open the solution file in Visual Studio 2015.
- Change connection string in the appsettings.json file.
- Run the following command for migration and create database.
Tools –> NuGet Package Manager –> Package Manager Console
PM> Add-Migration MyFirstMigration
- Run the application.
Running the Sample
To run the sample, hit F5 or choose the Debug | Start Debugging menu command. You will see the customer list screen. From this screen you have customer listing screen as shown in below figure.
Figure 1: Customer Listing
You can add new customer using the Add Customer button. You can edit individual customer using edit button in listing as shown in below figure.
Figure 2: Edit Customer
Now you can delete individual customer using delete button in listing as shown in below figure.
Figure 3: Delete Customer
Source Code Overview
Most of folders play same role as in MVC application but there are following more folder and files.
- wwwroot: It holds static js and css files.
- DbEntities: It holds DbContext and Entities to perform database operations.
- bundleconfig.json: It holds bundling and minification files information.
- project.json: It holds database connection string.
- Migrations: It holds database migration files.