You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
T4 template to exclude from the generated code database artifacts not used by EF Core at runtime #10890
Out of curiosity, have people actually been complaining about this? Is it really that hard to just remove the unwanted stuff from your model manually? I guess I put a high bar on extra command-line switches...
@roji Not disagreeing with you, but two things play the other way:
Large models, with 1000's of tables. This makes both the extra overhead more significant, and makes the guidance to make 1000's of edits somewhat unpalatable. We haven't had issues related to this specifically for large models, but several people have run into related issues.
Since there is no "update from database" our current guidance for a "database first" type flow is to re-generate the model when the database has changed. Adding in a bunch of manual edits as well makes this guidance even more unpalatable than it already is.
We use partial DbContext and Entity Classes, and each developer re-scaffolds on each schema change (we use SSDT project for the schema, so generate directly from the dacpac via EFPT, but might as well be from a local scratch database)
My comment on the docs page got merged into this issue.
From my perspective the constraint name is not necessary for the mapping. In fact, correct me if I'm wrong: I would assume that having the constraint name mapped would break the mapping if someone were to change the constraint name on the SQL side.
Why couple to the name by default? I would like to see the default omit anything that isn't necessary for the mapping, with an opt in for the extra bits for those that need/want it.
I put together a sample in bricelam/EFCore.TextTemplating showing how to use T4 templates to customize the code scaffolded by Scaffold-DbContext (and dotnet ef dbcontext scaffold). The default templates I provided only scaffold the things required to make EF Core work. Check it out if you're interested.
@bricelam, I took a look at your project for templating and it seems like just what the doctor ordered. A whole lot to learn, since I've never used the T4 templates, but seems like a great time to learn. Thanks for putting that together!
changed the title [-]RevEng: Option to omit artifacts unused by the runtime[/-][+]T4 template to exclude from the generated code database artifacts not used by EF Core at runtime[/+]on Oct 26, 2022
Activity
bricelam commentedon Feb 6, 2018
Update from Database may benefit from having the constraint names.
ErikEJ commentedon Feb 6, 2018
Great info, thanks Brice
roji commentedon Jul 31, 2018
See #12837 (comment) for some possible reservations...
Out of curiosity, have people actually been complaining about this? Is it really that hard to just remove the unwanted stuff from your model manually? I guess I put a high bar on extra command-line switches...
ajcvickers commentedon Jul 31, 2018
@roji Not disagreeing with you, but two things play the other way:
ErikEJ commentedon Jul 31, 2018
I use that workflow in production and it is actually not so bad...
ajcvickers commentedon Jul 31, 2018
@ErikEJ Good to hear! Including the manual edits? How much manual editing do you do, and how often does the database need to be re-scaffolded?
ErikEJ commentedon Jul 31, 2018
We dont do any manual edits.
We use partial DbContext and Entity Classes, and each developer re-scaffolds on each schema change (we use SSDT project for the schema, so generate directly from the dacpac via EFPT, but might as well be from a local scratch database)
sbrockway commentedon Nov 15, 2019
My comment on the docs page got merged into this issue.
From my perspective the constraint name is not necessary for the mapping. In fact, correct me if I'm wrong: I would assume that having the constraint name mapped would break the mapping if someone were to change the constraint name on the SQL side.
Why couple to the name by default? I would like to see the default omit anything that isn't necessary for the mapping, with an opt in for the extra bits for those that need/want it.
bricelam commentedon Feb 5, 2020
I put together a sample in bricelam/EFCore.TextTemplating showing how to use T4 templates to customize the code scaffolded by Scaffold-DbContext (and
dotnet ef dbcontext scaffold). The default templates I provided only scaffold the things required to make EF Core work. Check it out if you're interested.oliverkane commentedon Feb 22, 2020
@bricelam, I took a look at your project for templating and it seems like just what the doctor ordered. A whole lot to learn, since I've never used the T4 templates, but seems like a great time to learn. Thanks for putting that together!
ajcvickers commentedon Nov 10, 2021
Note: this will be possible once #4038 is implemented, which is planned for 7.0, and is already possible with the Power Tools.
[-]RevEng: Option to omit artifacts unused by the runtime[/-][+]T4 template to exclude from the generated code database artifacts not used by EF Core at runtime[/+]