articles

Home / DeveloperSection / Articles / update dbcontext from database using entity framework core in asp.net mvc core

update dbcontext from database using entity framework core in asp.net mvc core

update dbcontext from database using entity framework core in asp.net mvc core

Anonymous User7637 01-Dec-2020

Introduction:

In this we will explain how to update Entity Framework (EF) Core from database in asp.net  mvc core using package manager console visual studio 2019 and what is Entity Framework (EF) Core.

Description:

Here we are going to achieve how to update Entity Framework (EF) Core from database in mvc core using package manager console visual studio 2019. Before starting let’s know what is Entity Framework (EF) Core.

Entity Framework (EF) Core is a lightweight, extensible, and cross-platform version of the popular Entity Framework data access technology. EF Core is an object-relational mapper (O/RM) that enables .NET developers to work with a database using .NET objects.

To get more information about EF Core, I would recommend you to visit the official documentation here: https://docs.microsoft.com/en-us/ef/core/

Let’s start Update Entity Framework (EF) Core from database.

Goto > Tools > library package manager> package manager console > click .

Now open a window in bottom of screen then type following command line:

Scaffold-DbContext "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=collage;Data Source=(local)"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force

The Data Source attribute above is the SQL server instance name. You can find it in SQL Management

Studio by right clicking on your database. For this example, the server name is “SSAI-L005\SQLEXPRESS”.

The Database attribute is your database name. In this case, the database name is “Collage”.

The –OutputDir attribute allows you to specify the location of the files generated. In this case, we’ve set it

to Models.

The -force attribute use to update your model DBContext.

I hope it will help to you.


Updated 01-Dec-2020
I am a content writter !

Leave Comment

Comments

Liked By