Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold views into SQL definitions on the model #20940

Open
Tracked by #827 ...
mm-ryo opened this issue May 13, 2020 · 4 comments
Open
Tracked by #827 ...

Scaffold views into SQL definitions on the model #20940

mm-ryo opened this issue May 13, 2020 · 4 comments

Comments

@mm-ryo
Copy link

mm-ryo commented May 13, 2020

Hi,

I just run the Scaffold-DbContext command to generate DBModels. and we also want DB Views to be included in the generated DB Context. but we found the codes are not correct. it should call the ToView method instead of ToTable. please check the below codes. thank a lot.

modelBuilder.Entity("VTest", b =>
{
    b.Property<int?>("TestId1").HasColumnType("integer");
    b.Property<string>("TestId2").HasColumnType("text");
    b.ToTable("V_Test","public");
});

Steps to reproduce

Run below command

Scaffold-DbContext "****" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Models

Further technical details

EF Core version: 3.1.3
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL 3.1.3
Target framework: .NET Core 3.1
Operating system: Win 10
IDE: Visual Studio 2019 16.5.4

@mm-ryo mm-ryo changed the title Run Scaffold-DbContext to generate DBModels to include Db Views Run Scaffold-DbContext to generate DBModels, The codes are not correct with Db Views May 13, 2020
@roji
Copy link
Member

roji commented May 13, 2020

@robinNode EF Core doesn't currently support creating views in the database (see #14537 and #465), therefore it's not possible to scaffold views in a way that creates them as views.

@roji
Copy link
Member

roji commented May 13, 2020

Seems like we don't have a specific issue for tracking scaffolding of views to SQL definitions on the model, once #14537 is done (in #827?)

@ajcvickers
Copy link
Member

@roji I would add it to the list in #827 and use this issue to track the enhancement.

@ilmax ilmax mentioned this issue May 13, 2020
16 tasks
@roji roji changed the title Run Scaffold-DbContext to generate DBModels, The codes are not correct with Db Views Scaffold views into SQL definitions on the model May 13, 2020
@roji roji added this to the Backlog milestone May 13, 2020
@roji
Copy link
Member

roji commented May 13, 2020

@ajcvickers done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants