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

ModelConfiguration - Convention applied despite being overridden #28091

Closed
Jejuni opened this issue May 24, 2022 · 0 comments · Fixed by #29114
Closed

ModelConfiguration - Convention applied despite being overridden #28091

Jejuni opened this issue May 24, 2022 · 0 comments · Fixed by #29114
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported poachable type-bug
Milestone

Comments

@Jejuni
Copy link

Jejuni commented May 24, 2022

Description

Having a convention configured via ConfigureConventions (for instance, giving every decimal a precision and scale of 16,2) and then overriding that convention by calling HasPrecision fails when an entity is referenced as Owns AND OwnsMany within the same code base. In this instance one of the configured columns will have the correct (16,4) decimal definition while the other one will have the incorrect (16,2) definition.

Example:

Given these classes:

image

And this DbContext configuration:

image

Produces this unexpected migration:

image

Removing EITHER one of the 2 entities from the DbContext and Configuration returns the expected result of a column with a column type of decimal(16,4).

Repo

A Repo to quickly demonstrate the bug can be found here:
https://github.com/Jejuni/EfCoreConventionProblem

Provider and version information

EF Core version: 6.0.5 (tested in 6.0.4 - 6.0.5, but probably present in all version since introduction of convention feature)
dotnet-ef version 6.0.5
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.2.1

@AndriySvyryd AndriySvyryd self-assigned this May 26, 2022
@ajcvickers ajcvickers added this to the 7.0.0 milestone May 31, 2022
@ajcvickers ajcvickers self-assigned this Sep 13, 2022
ajcvickers added a commit that referenced this issue Sep 15, 2022
…s on making owned type shared

Fixes #28091

This is because property configuration done by pre-convention configuration is explicit, but if that has been changed before the type is made owned, then those changes are lost because the pre-convention configuration is not overwritten.
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 15, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-rc2 Sep 15, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-rc2, 7.0.0 Nov 5, 2022
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported poachable type-bug
Projects
None yet
3 participants