Generate Model from Existing Database in ASP.NET Core
Follow the steps to scaffold the model from existing database in Asp.Net Core:
1. Open your ASP.NET CORE project on Visual Studio.
2. Go to Tools > NuGet Package Manager > Package Manager Console.
3.Run the following command on the console
Install-Package Microsoft.EntityFrameworkCore.SqlServer
4. Again Run,
Install-Package Microsoft.EntityFrameworkCore.Tools
5.Again Run,
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
6.Again Run,
Scaffold-DbContext "Server=localdb)\mssqllocaldb;Database=TestDBName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Where "TestDBName" is Database name.
If you get an error like 'Scaffold-DbContext' is not known as the name of a cmdlet, then close and reopen Visual Studio.