This project shows how to use Entity Framework Core (SQLite) with NativeAOT. You may also use it as a starting point for your projects.
- A native C++ build toolchain: MSVC or clang
- .NET 6.0 SDK
You need to clone this project to your local development environment first:
git clone https://github.com/hez2010/EFCore.NativeAOT.git
cd EFCore.NativeAOT
Then you can build the project:
dotnet publish -c Release -r win-x64
win-x64
can be replaced to other runtime identifiers, e.g. linux-x64
, osx-x64
, linux-arm64
, win-arm64
and etc.
The built dist will be placed in publish
directory, for example, bin/Release/net6.0/win-x64/publish
.
You may want to access the endpoint /WeatherForecast
to see the insert and query result.
To split things out, I moved all NativeAOT related things to Directory.Build.props
including references to NativeAOT compiler and rd.xml
. You can simply move them back to the csproj file if you don't want a Directory.Build.props
separately.