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

Consider removing the partial trimming annotations introduced in EF Core 7.0 #29763

Open
Tracked by #29754 ...
roji opened this issue Dec 4, 2022 · 1 comment
Open
Tracked by #29754 ...

Comments

@roji
Copy link
Member

roji commented Dec 4, 2022

For EF Core 7.0, we introduced some trimming annotations to make basic scenarios work with aggressive trimming, the new default for console application (#29092). The main goal there was to prevent properties on entity CLR types from being trimmed, since EF accesses them at runtime via reflection and the linker cannot see that. For example, the T in DbSet<T> was annotated to preserve all constructors/properties; but entity types without an explicit DbSet property (e.g. discovered via navigations) would still fail, and require explicit user intervention.

We are now exploring a full AOT approach to EF, where materializers are generated as C# code into the user's project. In that world, the above partial annotations are no longer needed, since the linker can see EF's access in plain (generated) C# code. We should consider removing these annotations.

This would mean that EF's trimming story is coupled to its AOT story (EF's AOT, not NativeAOT), i.e. we don't fully support trimming without AOT; or more precisely, if the user does trimming without AOT, it's their responsibility to annotate their own types as appropriate. I think this makes sense, since we can't fully solve this problem anyway (e.g. entity types discovered via navigations).

@roji
Copy link
Member Author

roji commented Dec 8, 2022

Note that these annotations potentially cause bloat, since they cause user POCOs to not get trimmed when they could be. On the other hand, they do provide a bit of assistance for trimming when AOT (precompiled queries) isn't in use. We'll discuss this in design and decide what to do.

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

No branches or pull requests

2 participants