Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Core 2.0 Scaffold view from existing database

Is it possible to scaffold view from existing database in Entity Framework Core 2.0?

Something like command below:

Scaffold-DbContext "Server=xxx;Database=xxx; User Id=xxx; Password=xxx;"  
                   Microsoft.EntityFrameworkCore.SqlServer        
                   -OutputDir Models -Context TestStare 
                   -Tables Osebe -Views View1 -Force
like image 251
Matej Avatar asked Nov 21 '17 15:11

Matej


People also ask

How does Entity Framework connect to database?

During installation, the EntityFramework NuGet package checks which database server is available. The NuGet package will then update the configuration file by setting the default database server that Code First uses when creating a connection by convention.

How do I add Entity Framework to an existing project?

Install Entity FrameworkRight click on your project name and select Manage NuGet Packages. Go to Browse and Select Entity Framework then click Install button to install Entity Framework on your project.


2 Answers

From EF Core 3.0 it is possible to scaffold views and keyless entities Excerpt from Docs

Query types, which represent data that can be read from the database but not updated, have been renamed to keyless entity types. As they are an excellent fit for mapping database views in most scenarios, EF Core now automatically creates keyless entity types when reverse engineering database views.

like image 165
Tassadaque Avatar answered Sep 20 '22 14:09

Tassadaque


No, it is not supported, currently in the Backlog: https://github.com/aspnet/EntityFrameworkCore/issues/1679

like image 25
ErikEJ Avatar answered Sep 21 '22 14:09

ErikEJ