-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Owned attribute adds TempId column to principal entity when foreign key type has conversion #27549
Comments
v6.0.6 has same bug even when entity is configured with modelBuilder in Is there a workaround that would prevent TempId column declarations from being generated into the migration? |
A possible workaround could be calling |
Propagate value converters to FKs Fixes #27549
FYI |
This is breaking change between efcore 5 and efcore 6.
I have the following model where an owned entity has foreign key to another entity. The key property is of type
MyId
and thus needs a conversion to be configured.If the owned entity is configured as owned via
OwnedAttribute
, then the referencedBarEntity
entity by foreign key gets columnTempId
, which shouldn't be there (see the generated migration bellow).If the owned entity is configured with
modelBuilder
inOnModelCreating
method using.OwnsOne()
(without usingOwnedAttribute
onOwnedBazEntity
), theTempId
column is not created (as expected).Model
DbContext
Create init migration
dotnet ef migrations add Init
Actual result
Expected result
Provider and version information
EF Core version: 6.0.2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Nullability: enabled
Operating system: Win10 21H1 19043.1526
IDE: Visual Studio 2022 17.1 Preview 6.0
The text was updated successfully, but these errors were encountered: