0

I have a single database that has multiple schema's. The two schemas are Bob and Bill. Both Bob and Bill contain Table1 Table2 and Table3. When I call Scaffold-DbContext it to just generate scaffold for Table1, Table2, Table3 for a single schema "Bob" which is what I thought I would run this command.

Scaffold-DbContext -t Table1 Table2 Table3 -schema "Bob" 

When I run that command I get all tables in the database including Table1, Table2, Table3 from Both Schema's why is this and what can I do to just get a single schema and Table1, Table2, Table3

1
  • The right argument is -schemas "Bob" - see scaffold-dbcontext Commented Dec 6, 2024 at 17:37

2 Answers 2

5

Use only -t option with schema.tablename syntax

Sign up to request clarification or add additional context in comments.

2 Comments

Thank-you so much! This is a life saver!
for multiple schemas, and specific tables, how would i go about it? right now, i am trying this but it get ALL the tables from the mentioned schemas. Scaffold-DbContext "My-postgresql-connectionstring" Npgsql.EntityFrameworkCore.PostgreSQL -o DbModels -UseDatabaseNames -Force -Context "PgDbContext" -Schema "schema1", "schema2" -t schema1.table1, schema1.table2, schema2.table11, schema2.table22. What am i doing wrong and where is it going wrong?
3

To be clear, multiple table names should also be comma separated:

Scaffold-DbContext -t Bob.Table1, Bob.Table2, Bob.Table3

If any table name contains spaces (somethings out of our control), quote the table name as well:

Scaffold-DbContext -t "Bob.Table 1", "Bob.Table 2", "Bob.Table 3"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.