-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
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). |
I think the schema should always be scaffolded. |
@ErikEJ the schema on each table or the default one? Can you elaborate a bit more on why? 😄 |
I meant be explicit on each table... Because this is scaffolding, and should reflect the actual layout of the db. |
@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. |
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. |
@bricelam will revisit this when he is working on update model from database. |
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?
The text was updated successfully, but these errors were encountered: