Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make property instances non-owned.
  • Loading branch information
sbodenschatz committed Mar 25, 2022
1 parent 56853f8 commit 6effe1c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public static ModelBuilder KeyValuePropertiesBetween<TDefinitionOwner, TInstance
def.HasIndex(uniqueOwnerAndNameIndexPropNames).IsUnique();
def.Property(d => d.Name).HasMaxLength(nameLength);
});
instanceOwner.OwnsMany(instanceExpression, inst => {
var ownership = inst.WithOwner(pi => pi.Owner);

var instancesRel = instanceOwner.HasMany(instanceExpression).WithOne(pi => pi.Owner);
modelBuilder.Entity<TInstance>(inst => {
var defFK = inst.HasOne(pi => pi.Definition).WithMany();
var uniqueDefAndOwnerIndexPropNames = defFK.Metadata.Properties.Concat(ownership.Metadata.Properties).Select(p => p.Name).ToArray();
var uniqueDefAndOwnerIndexPropNames = defFK.Metadata.Properties.Concat(instancesRel.Metadata.Properties).Select(p => p.Name).ToArray();
inst.HasIndex(uniqueDefAndOwnerIndexPropNames).IsUnique();
inst.Property(pi => pi.IntegerValue);
inst.Property(pi => pi.FloatingPointValue);
Expand Down

0 comments on commit 6effe1c

Please sign in to comment.