dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.77k stars 3.18k forks source link

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

Open AndriySvyryd opened 2 years ago

AndriySvyryd commented 2 years ago

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

viniciusverasdossantos commented 2 years ago

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

ronymeyer commented 2 years ago

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

ajcvickers commented 10 months ago

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

roji commented 10 months ago

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...

AndriySvyryd commented 10 months ago

should we maybe consider just always fully-qualifying?

Sure and we can add an opt-out instead

roji commented 10 months ago

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?

AndriySvyryd commented 10 months ago

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

ajcvickers commented 9 months ago

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.