DB or Database First Approach in Entity Framework Core & Asp.Net Core 5 & 3.1 to Create Models

Published: 02 March 2021
on channel: localhost
5,729
83

DB or Database first approach in Entity Framework Core example to fetch data from a table and generate the model from database entity framework core. In this tutorial, you can find everything related to DB first approach in Asp.Net Core 5 and 3.1. If you are using .Net core 3.1 or 3.0 then make sure to install the latest packages which we have defined in this database first approach in the Entity Framework core tutorial. In this video, you will also learn to Create Models from an existing database using EF Core.

Step 1: Install the below packages from the Nuget Package Manager console
1. Microsoft.EntityFrameworkCore​
2. Microsoft.EntityFrameworkCore.Design​
3. Microsoft.EntityFrameworkCore.SqlServer​
4. Microsoft.EntityFrameworkCore.Tools

Step 2: Add connectionString in the config file as explained in entity framework core database first approach tutorial

Step 3: Run the below command in Nuget Package Manager console:
Scaffold-DbContext "Server=.\SQLEXPRESS;Initial Catalog=WebAPI;MultipleActiveResultSets=true;User ID=sa;Password=123456;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models​

Step 4: Add created DatabaseContext in Statup.cs file
Step 5: Add Dependency Injection or Inversion of Control (IOC):
private readonly MyDbContext _dbContext;

Step 6: Create Action Method to get the Data from the database table

After following the above EF core steps you will be able to create the model from the database using entity framework core in Asp.Net Core 3.1 and 5.


Please find the Project and Notepad link below:
https://drive.google.com/drive/folder...


Go to this link to take the test to identify yourself.
https://oktests.com/

Like us on Facebook:   / oktests  


Watch video DB or Database First Approach in Entity Framework Core & Asp.Net Core 5 & 3.1 to Create Models online without registration, duration hours minute second in high quality. This video was added by user localhost 02 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,72 once and liked it 8 people.