Skip to content

Store database type name in model snapshot - #16484

Merged
ajcvickers merged 1 commit into
masterfrom
MagicRoundabout0705
Jul 7, 2019
Merged

ajcvickers merged 1 commit into
masterfrom
MagicRoundabout0705

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Fixes #16239
Fixes #12212

Also, make the SnapshotModelProcessor finalize the model.

I investigated whether it would be better to only store this sometimes, but that then still requires making some assumptions (basically using some conventions and/or the type mapper doing what it does in conventions) when loading the snapshot to ensure we find the right type for the provider being used. Storing it always is clean and simple, decouples from conventions when loading, and means we don't have to do special magic for facets that come from value converters.

Fixes #16239
Fixes #12212

Also, make the SnapshotModelProcessor finalize the model.

I investigated whether it would be better to only store this sometimes, but that then still requires making some assumptions (basically using some conventions and/or the type mapper doing what it does in conventions) when loading the snapshot to ensure we find the right type for the provider being used. Storing it always is clean and simple, decouples from conventions when loading, and means we don't have to do special magic for facets that come from value converters.
@ajcvickers
ajcvickers merged commit e454071 into master Jul 7, 2019
@ghost
ghost deleted the MagicRoundabout0705 branch July 7, 2019 16:05

@bricelam bricelam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

.Append(".")
.Append(nameof(RelationalPropertyBuilderExtensions.HasColumnType))
.Append("(")
.Append(Code.UnknownLiteral(property.GetColumnType()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code.Literal() is preferred when they type is statically known.


b.Property<decimal>(""EnumU64"")
.HasConversion(new ValueConverter<decimal, decimal>(v => default(decimal), v => default(decimal), new ConverterMappingHints(precision: 20, scale: 0)));
.HasColumnType(""decimal(20,0)"");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

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.

Model snapshot is used without type mappings Snapshot should preserve the property CLR type when value conversion is used

3 participants