Efcore: Scaffold-DBContext returns table and views from all schemas

Created on 24 Jan 2020  Â·  5Comments  Â·  Source: dotnet/efcore

if you use -schema, you will get all the tables AND VIEWS in that schema, even though you have provided a table list.
if you provide a table list but no schema, you will get both tables and views from all schemas in the db.
or have I missed something?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

area-scaffolding customer-reported good first issue poachable punted-for-5.0 type-bug

Most helpful comment

You can use:

Scaffold-DbContext -Tables X.A

All 5 comments

@baltmann Thanks for reporting; this does sound like a bug.

@ErikEJ?

OK, I see two issues reported here:

if you use -schema, you will get all the tables AND VIEWS in that schema, even though you have provided a table list.

I do not use that feature in EF Core Power Tools (I provide an explicit list of table and view names, so there might be an issue here - but an example/repro would be very useful (SQL table/view create scripts and used command line)

if you provide a table list but no schema, you will get both tables and views from all schemas in the db. or have I missed something?

An example would be nice (SQL table/view create scripts and used command line) , I have not encountered this with EF Core Power Tools.

Will transfer to produce repo once transfer is available again.

@ajcvickers

if you use -Schemas, you will get all the tables AND VIEWS in that schema, even though you have provided a table list.

Is this behavior going to change in 5.0, for example with SQL Server EFCORE provider?
Currently, I suppose it will scaffold all the tables in that schema even though a table list is specified using -Tables.

Consider a user has access to schemas X and Y and tables A and B exist in each of these schemas.

Now if the user wants to scaffold (reverse engineer) only table A in schema X, then the user would have to execute a command such as this:
Scaffold-DbContext -Schemas X -Tables A

But I suppose it will scaffold all the tables in schema X.
Is there a way to get the behavior that the user actually wanted?

You can use:

Scaffold-DbContext -Tables X.A
Was this page helpful?
0 / 5 - 0 ratings