This question is locked. New answers and comments are not allowed.
Hello,
I'm fairly new to using Telerik Data Access and I tried searching for this exact issue in the forum but didn't find it. I am trying to set up a 1:1 relationship on an entity that is using vertical inheritance, however, when I try to add the constraint I get the following error:
The property Id is not mapped to a column. (Id is my primary key.)
Parent class mapping
parentConfig.MapType()
.ToTable("Parent");
parentConfig.HasProperty(t => t.Id)
.IsIdentity(KeyGenerator.Guid);
Inherited/child mapping
childConfig.MapType()
.Inheritance(InheritanceStrategy.Vertical)
.ToTable("Child");
childConfig.HasAssociation(t => t.ChildAssociation)
.HasConstraint((c, l) => c.Id == l.Id) --This is causing the issue
.AsOneToOne()
.IsRequired();
childConfig.HasDiscriminatorValue("1");
Association mapping
associationConfig.MapType()
.ToTable("ChildAssociation");
associationConfig.HasProperty(t => t.Id)
.IsIdentity(KeyGenerator.Guid);
It seems that since the Id property is mapped on the parent type, the HasConstraint method doesn't recognize it on the derived type. I did manage to get a 1:1 relationship setup on two classes that have no inheritance mapping. Is there a workaround for this or is there something I am missing? Thanks.
I'm fairly new to using Telerik Data Access and I tried searching for this exact issue in the forum but didn't find it. I am trying to set up a 1:1 relationship on an entity that is using vertical inheritance, however, when I try to add the constraint I get the following error:
The property Id is not mapped to a column. (Id is my primary key.)
Parent class mapping
parentConfig.MapType()
.ToTable("Parent");
parentConfig.HasProperty(t => t.Id)
.IsIdentity(KeyGenerator.Guid);
Inherited/child mapping
childConfig.MapType()
.Inheritance(InheritanceStrategy.Vertical)
.ToTable("Child");
childConfig.HasAssociation(t => t.ChildAssociation)
.HasConstraint((c, l) => c.Id == l.Id) --This is causing the issue
.AsOneToOne()
.IsRequired();
childConfig.HasDiscriminatorValue("1");
Association mapping
associationConfig.MapType()
.ToTable("ChildAssociation");
associationConfig.HasProperty(t => t.Id)
.IsIdentity(KeyGenerator.Guid);
It seems that since the Id property is mapped on the parent type, the HasConstraint method doesn't recognize it on the derived type. I did manage to get a 1:1 relationship setup on two classes that have no inheritance mapping. Is there a workaround for this or is there something I am missing? Thanks.