Skip to content

Support type mappings in NativeAOT compiled models. - #1295

Open
niekschoemaker wants to merge 1 commit into
FirebirdSQL:masterfrom
niekschoemaker:compiled-model-nativeaot-type-mappings
Open

niekschoemaker wants to merge 1 commit into
FirebirdSQL:masterfrom
niekschoemaker:compiled-model-nativeaot-type-mappings

Conversation

@niekschoemaker

Copy link
Copy Markdown
Contributor

dotnet ef dbcontext optimize --nativeaot failed because the Firebird type mappings had no public static Default property. Every Fb*TypeMapping now has one.
The generated code recreates a mapping as Default.Clone(...) from the standard RelationalTypeMappingParameters only, so FbDateTimeTypeMapping, FbStringTypeMapping and FbTimeSpanTypeMapping additionally expose FbDbType and Clone(FbDbType), and the new FbCSharpRuntimeAnnotationCodeGenerator emits that Clone when the FbDbType differs from the one of Default (e.g. DATE vs TIMESTAMP, CHAR vs VARCHAR).

The solutions employed here follow the same approach as the postgresql provider. So the generation of the Clone method when the type mapping isn't the exact mapping from Default.

This code has been generated by AI, and was manually reviewed by me.

I think this also covers a small part of issue #1096, but only the part where precompiled queries and models from efcore will work.

dotnet ef dbcontext optimize --nativeaot failed because the Firebird type mappings had no public static Default property.
Every Fb*TypeMapping now has one. The generated code recreates a mapping as Default.Clone(...) from the standard
RelationalTypeMappingParameters only, so FbDateTimeTypeMapping, FbStringTypeMapping and FbTimeSpanTypeMapping
additionally expose FbDbType and Clone(FbDbType), and the new FbCSharpRuntimeAnnotationCodeGenerator emits that
Clone when the FbDbType differs from the one of Default (e.g. DATE vs TIMESTAMP, CHAR vs VARCHAR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@niekschoemaker
niekschoemaker marked this pull request as ready for review November 4, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant