I have an existing database in SQL Server that I need to connect to ASP.NET Core 2.2 project with EF Core. I scaffolded the models and the DbContext via the Scaffold-DbContext command in Package Manager Console. I can access all the data from the tables. However this didn't scaffold the procedures or the views.
This is a major obstacle to starting to use ASP.NET Core in our apps. Is there any way we could circumvent this? Can it be done in ASP.NET Core 2.2 or in a later version?
Can it be done in ASP.NET Core 2.2 or in a later version?
In .NET Core 3.1 (and seemingly 3.0) there is support for views. See Reverse engineering of database views in New features in Entity Framework Core 3.0.
It still uses --table
or -t
, or will be picked up with all the other tables and views if you don't pass particular tables/views.
dotnet ef dbcontext scaffold "Connection-String-Information" Microsoft.EntityFrameworkCore.SqlServer -o ModelsFolderName -c DbContextName -d -v --table viewName
The name of the class will be prefixed with a V
.