efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Add a parameter to `Optimize-DbContext` for fully qualifying types

Open AndriySvyryd opened this issue 3 years ago • 8 comments

See https://github.com/dotnet/efcore/issues/25523#issuecomment-1014681765

AndriySvyryd avatar Jan 18 '22 06:01 AndriySvyryd

There is an alternative solution? My domain has many entities and I have more than 400 conflicts

viniciusverasdossantos avatar Sep 20 '22 02:09 viniciusverasdossantos

There is an alternative solution? My domain has many entities and I have more than 400 conflicts

Workaround is mentioned here: https://github.com/dotnet/efcore/issues/25523#issuecomment-902836615

ronymeyer avatar Sep 20 '22 07:09 ronymeyer

Adding a note to help me find this in the future; fully-qualified typed for compiled model. :-)

ajcvickers avatar Jan 09 '24 16:01 ajcvickers

Just because I just saw this: should we maybe consider just always fully-qualifying? I think that's generally consider best practice in generated code (dealt with some similar issues in precompiled queries), and there's no real downside except more verbose generated code, which nobody cares about...

roji avatar Jan 09 '24 17:01 roji

should we maybe consider just always fully-qualifying?

Sure and we can add an opt-out instead

AndriySvyryd avatar Jan 09 '24 21:01 AndriySvyryd

FWIW it seems to be standard practice (e.g. in source generators) for generated code to just always be fully-qualified (including the global:: prefix for maximum disambiguation). Given that this is generated code and readability shouldn't be a big priority, is it worth even having an opt-out?

roji avatar Jan 10 '24 08:01 roji

For big models this could mean a lot of additional code, like tens of megabytes more.

AndriySvyryd avatar Jan 10 '24 08:01 AndriySvyryd

Note from triage: we should do this by default, since the code is not intended to be edited, but with a switch to turn it off due to the increase in size.

ajcvickers avatar Jan 18 '24 11:01 ajcvickers