How to define Foreign Key in a value object #7368
-
Hi, Address class has a CityId property pointing City class Childs table has an Address_CityId column.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello, And i did't catch this
Happy code |
Beta Was this translation helpful? Give feedback.
Hello,
If Address is value object related to City Calss, you have to said that CityClass
b.OwnsOne(x => x.Address , o => { o.Property(q => q.Street).HasColumnName(nameof(Address.Street)); o.Property(q => q.Number).HasColumnName(nameof(Address.Number)); o.Property(q => q.Zipcode).HasColumnName(nameof(Address.Zipcode)); });
I removed cityId from the Address ( value object ) because they will added in the City.
If you wanna split your Class and Value object u have to add cityId in the value object.
And i did't catch this
Happy code