owned-types

EF Core 2.2, owned entities generated as another table when multiple in hierarchy

我怕爱的太早我们不能终老 提交于 2021-02-08 17:32:28
问题 I have a model with a class Address marked [Owned] and a hierarchy of people (person, customer or employee, then even more subtypes etc). There are addresses at different stages of this hierarchy and all of it ends up in one table as EF Core is limited to table per hierarchy. I expected all the attributes from address to appear multiple times in that person table (once per mention in any of the subtypes) however it doesn't appear at all! Instead i see FK for each of them and a separate

EF Core 2.2, owned entities generated as another table when multiple in hierarchy

橙三吉。 提交于 2021-02-08 17:29:55
问题 I have a model with a class Address marked [Owned] and a hierarchy of people (person, customer or employee, then even more subtypes etc). There are addresses at different stages of this hierarchy and all of it ends up in one table as EF Core is limited to table per hierarchy. I expected all the attributes from address to appear multiple times in that person table (once per mention in any of the subtypes) however it doesn't appear at all! Instead i see FK for each of them and a separate

EF Core 2.2, owned entities generated as another table when multiple in hierarchy

不想你离开。 提交于 2021-02-08 17:26:55
问题 I have a model with a class Address marked [Owned] and a hierarchy of people (person, customer or employee, then even more subtypes etc). There are addresses at different stages of this hierarchy and all of it ends up in one table as EF Core is limited to table per hierarchy. I expected all the attributes from address to appear multiple times in that person table (once per mention in any of the subtypes) however it doesn't appear at all! Instead i see FK for each of them and a separate

EF Core 2.2, owned entities generated as another table when multiple in hierarchy

那年仲夏 提交于 2021-02-08 17:25:05
问题 I have a model with a class Address marked [Owned] and a hierarchy of people (person, customer or employee, then even more subtypes etc). There are addresses at different stages of this hierarchy and all of it ends up in one table as EF Core is limited to table per hierarchy. I expected all the attributes from address to appear multiple times in that person table (once per mention in any of the subtypes) however it doesn't appear at all! Instead i see FK for each of them and a separate

How can I create a Required Owned Type with Entity Framework Core 3.0

陌路散爱 提交于 2020-08-07 08:03:50
问题 I'm struggling creating a non-nullable/required Owned Type with Entity Framework Core. I'm using EF Core 3.0 against PostgreSQL database. My value object: public class PersonName { public PersonName(string name) { this.Name = name; } public string Name { get; set; } } My entity: public class Person { public int Id { get; set; } public virtual PersonName FullName { get; set; } } My entity configuration: public void Configure(EntityTypeBuilder<Person> builder) { builder.ToTable(nameof(Person));

How can I create a Required Owned Type with Entity Framework Core 3.0

泪湿孤枕 提交于 2020-08-07 08:03:11
问题 I'm struggling creating a non-nullable/required Owned Type with Entity Framework Core. I'm using EF Core 3.0 against PostgreSQL database. My value object: public class PersonName { public PersonName(string name) { this.Name = name; } public string Name { get; set; } } My entity: public class Person { public int Id { get; set; } public virtual PersonName FullName { get; set; } } My entity configuration: public void Configure(EntityTypeBuilder<Person> builder) { builder.ToTable(nameof(Person));

One-to-one and one-to-many relationships with same owned entity type

≡放荡痞女 提交于 2020-06-29 04:14:31
问题 After this question I tried working with owned entity types but I'm stuck at the following scenario: public class User { [Key] public Guid UserId { get; set; } public ICollection<Listing> Listings { get; set; } public Image Avatar { get; set; } } public class Listing { [Key] public Guid ListingId { get; set; } public ICollection<Image> Photos { get; set; } } [Owned] public class Image { public long Size { get; set; } public string Height { get; set; } public string Width { get; set; } }

Entity Framework Core 2.1 - owned types and nested value objects

笑着哭i 提交于 2020-06-23 07:23:32
问题 I'm learning DDD and the tutorial I'm currently following is implemented using NHibernate, but since my lack of experience with it I've decided to go through the course using EF Core 2.1. However, I'm currently a bit stuck with the following: I have three classes Customer which is an entity and two value objects ( CustomerStatus and inside of it value object ExpirationDate ) - like this: public class Customer : Entity { //... constructor, other properties and behavior omitted for the sake of