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.55k stars 3.13k forks source link

Don't use reflection at runtime #24903

Open AndriySvyryd opened 3 years ago

AndriySvyryd commented 3 years ago

This is a grouping of related issues. Feel free to vote (👍) for this issue to indicate that this is an area that you think we should spend time on, but consider also voting for individual issues for things you consider especially important.


The code that currently uses reflection and expression compilation at runtime can be precompiled:

This would allow to remove all reflection data from the compiled model (e.g. IReadOnlyTypeBase.ClrType, IReadOnlyPropertyBase.PropertyInfo) and significantly improve AOT experience.

Noemata commented 3 years ago

@AndriySvyryd , totally agree. I'd be interesting in helping with this if there was a commitment to support UWP from the get go.

hez2010 commented 2 years ago

efcore is using assembly loading which is incompatible with NativeAOT: https://github.com/dotnet/efcore/blob/b3619b49eb43fdeb8c93d167f2bc1fd67c2735ec/src/Microsoft.Data.Sqlite.Core/Utilities/BundleInitializer.cs#L20

Though it can be mitigated by calling SQLitePCL.Batteries_V2.Init() manually before efcore context setup (thanks to the try-catch block).