asp.net existing database code example

Example: asp.net existing database

# tested on Visual Studio 2019
# install these packages via View>Other windows>Package Manager Console
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Design
Install-Package Microsoft.EntityFrameworkCore.Tools

# then scaffold the dbContext via your connection string
Scaffold-DbContext "Server=<serverName>"; Initial Catalog=<database>; 
  User ID=<username>; Password=<password>; Microsoft.EntityFrameworkCore.SqlServer 
  -OutputDir Models -Context CoreDbContext - DataAnnotations