Skip to content

How to define Foreign Key in a value object #7368

Answered by amsaighi
liorbalmas asked this question in Q&A
Discussion options

You must be logged in to vote

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

  • Child class has an Address property.-
  • Childs table has an Address_CityId column.

Happy code

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@liorbalmas
Comment options

Answer selected by liorbalmas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants