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 a subset of tables - silently ignores / skips tables that cannot be found #4168

Closed
dazinator opened this issue Dec 23, 2015 · 9 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. providers-beware type-bug
Milestone

Comments

@dazinator
Copy link

I have an existing database that I'd like to scaffold a DbContext from, but only for a subset of the tables in this database.

I tried:

dnx ef dbcontext scaffold "connstring" EntityFramework.MicrosoftSqlServer --outputDir Models --table dbo.table1 --table dbo.table2

UPDATE: This doesn't work - it seemed to only scaffold the second table.

This does work, but the table names are case sensitive, and if you get the casing wrong, then it seems to silently skip the scaffolding of that table.

I think it should output a warning to say that a table was skipped for some reason.

@ErikEJ
Copy link
Contributor

ErikEJ commented Dec 23, 2015

Have you tried "-t" ie no double hyphens?

@dazinator
Copy link
Author

Oh yikes - tried using -t dbo.table1 -t dbo.table2 and this time it worked.. which led me to re-look at the issue. --table dbo.table1 --table dbo.table2 also worked! So how come it didn't work when I first tried? Well.. the table names are case sensitive, and if you get the casing wrong it appears to be silently ignored when scaffolding - and this made me think that it was only ever doing one table but really it was silently ignoring the one with incorrect casing.

I think if it doesn't like a table it should probably output a warning of some kind to say that it skipped scaffolding for a table because it couldn't find it! :)

Thanks for prompting me to relook at this and figure it out!

@dazinator dazinator changed the title Scaffold a subset of tables Scaffold a subset of tables - silently ignores / skips tables that cannot be found Dec 23, 2015
@ErikEJ
Copy link
Contributor

ErikEJ commented Dec 23, 2015

I think it should not be case sensitive at all!

@rowanmiller
Copy link
Contributor

I think it should not be case sensitive at all

Agreed, as I don't think any of the major relational databases let table names only differ by case.

I think if it doesn't like a table it should probably output a warning of some kind to say that it skipped scaffolding for a table because it couldn't find it

Also agreed, since you explicitly asked for that table to be included

@rowanmiller rowanmiller added this to the 7.0.0-rc2 milestone Jan 6, 2016
@rowanmiller
Copy link
Contributor

@lajones we should warn if the table is not found. Case sensitivity should be up to the provider (and ours should not be case sensitive).

@lajones
Copy link
Contributor

lajones commented Jan 7, 2016

Note: case-sensitivity was fixed by @ErikEJ with bfc8da1 (Thanks Erik).

@lajones
Copy link
Contributor

lajones commented Jan 7, 2016

Note: each provider interprets the --schema and --table selections according to its own rules (e.g. the SQL Server provider allows you to pass [schema].[table] as well as schema.table) - and so will also need to be responsible for the functionality that interprets whether those selections have been satisfied.

@lajones
Copy link
Contributor

lajones commented Jan 11, 2016

Fix checked in with PR#4252. Commit 50c51e7.

@sreejithvijayan
Copy link

If anyone got the below error,

Scaffold-DbContext : Cannot bind parameter because parameter 'Tables' is specified more than once. To provide multiple values to parameters that can accept multiple values, use
the array syntax. For example, "-parameter value1,value2,value3".At line:1 char:335

Then try the following format,

dnx ef dbcontext scaffold "connstring" EntityFramework.MicrosoftSqlServer --outputDir Models -t dbo.table1, dbo.table2

then try the following command

@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. providers-beware type-bug
Projects
None yet
Development

No branches or pull requests

6 participants