Introduction:

In this we will learn how to Add Entity Framework (EF) Core from database in mvc core using package manager console visual studio 2017 and what is Entity Framework (EF) Core.

Description:

Here we are going to achieve how to add Entity Framework (EF) Core from database in mvc core using package manager console visual studio 2017. 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=ITD-WS-047"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

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 “ASU-LP05\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.


after executing above code output will be shown like below:

Output:



I hope it will help to you.


0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Welcome to SQL Tutorials Point

Don't have an account? Click here to Create a new account, it takes less than a minute.