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

SqlServer RevEng: Scaffold default schema #9318

Open
Tracked by #22948
smitpatel opened this issue Aug 2, 2017 · 7 comments
Open
Tracked by #22948

SqlServer RevEng: Scaffold default schema #9318

smitpatel opened this issue Aug 2, 2017 · 7 comments

Comments

@smitpatel
Copy link
Member

At present we identify the default schema using SELECT SCHEMA_NAME()
But default schema is user specific. So different users may have different schema. This can give rise to different scaffolded code based on who ran the rev eng & cause ugly version control diffs especially once update model for database is implemented.

If we stop scaffolding default schema then if the schema is anything other than "dbo" (which is our default) then it will be used in scaffolding objects. (like ToTable("tablename", "nondefaultschema")) but it will produce more consistent code across users.

Another option is to take command line argument for default schema so user can specify what to consider as default schema as opposed to we trying to guess based on user. But we can defer this to customer feedback.

@bricelam - comments?

@bricelam
Copy link
Contributor

bricelam commented Aug 2, 2017

dbo is not our default (except for functions). If you don't specify a schema, we don't specify one in SQL and the default schema of the current user is used.

The way we currently scaffold means that no matter what user you use to reverse engineer, it should work for all users if they have access to the objects.

It may be helpful to have an option never to use the default schema (always configure it on each table).

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 2, 2017

I think the schema should always be scaffolded.

@divega
Copy link
Contributor

divega commented Aug 2, 2017

@ErikEJ the schema on each table or the default one? Can you elaborate a bit more on why? 😄

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 2, 2017

I meant be explicit on each table... Because this is scaffolding, and should reflect the actual layout of the db.

@divega
Copy link
Contributor

divega commented Aug 2, 2017

@ErikEJ I don't think that is necessarily bad, but we also as a principle try to avoid generating repetitive code that the default conventions makes unnecessary.

@divega
Copy link
Contributor

divega commented Aug 2, 2017

If you don't specify a schema, we don't specify one in SQL

FWIW, in SQL Server there is supposedly a performance overhead when schema is not specified in the SQL, because it needs to run some heuristics to resolve the table. I can't remember if ever tried to measure that.

@divega divega added this to the 2.1.0 milestone Aug 2, 2017
@divega
Copy link
Contributor

divega commented Aug 2, 2017

@bricelam will revisit this when he is working on update model from database.

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

Successfully merging a pull request may close this issue.

6 participants