|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | + |
| 5 | +using Microsoft.EntityFrameworkCore.TestModels.RelationshipsModel; |
| 6 | + |
| 7 | +namespace Microsoft.EntityFrameworkCore.Query.Relationships; |
| 8 | + |
| 9 | +public abstract class OwnedRelationshipsQueryRelationalFixtureBase : OwnedRelationshipsQueryFixtureBase |
| 10 | +{ |
| 11 | + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) |
| 12 | + { |
| 13 | + base.OnModelCreating(modelBuilder, context); |
| 14 | + |
| 15 | + modelBuilder.Entity<RelationshipsRootEntity>().ToTable("RootEntities"); |
| 16 | + modelBuilder.Entity<RelationshipsRootEntity>() |
| 17 | + .OwnsOne(x => x.OptionalReferenceTrunk, b => |
| 18 | + { |
| 19 | + b.OwnsOne(x => x.OptionalReferenceBranch, bb => |
| 20 | + { |
| 21 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 22 | + { |
| 23 | + bbb.ToTable("Root_OptionalReferenceTrunk_OptionalReferenceBranch_CollectionLeaf"); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + b.OwnsOne(x => x.RequiredReferenceBranch, bb => |
| 28 | + { |
| 29 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 30 | + { |
| 31 | + bbb.ToTable("Root_OptionalReferenceTrunk_RequiredReferenceBranch_CollectionLeaf"); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + b.OwnsMany(x => x.CollectionBranch, bb => |
| 36 | + { |
| 37 | + bb.ToTable("Root_OptionalReferenceTrunk_CollectionBranch"); |
| 38 | + |
| 39 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 40 | + { |
| 41 | + bbb.ToTable("Root_OptionalReferenceTrunk_CollectionBranch_CollectionLeaf"); |
| 42 | + }); |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + modelBuilder.Entity<RelationshipsRootEntity>() |
| 47 | + .OwnsOne(x => x.RequiredReferenceTrunk, b => |
| 48 | + { |
| 49 | + b.OwnsOne(x => x.OptionalReferenceBranch, bb => |
| 50 | + { |
| 51 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 52 | + { |
| 53 | + bbb.ToTable("Root_RequiredReferenceTrunk_OptionalReferenceBranch_CollectionLeaf"); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + b.OwnsOne(x => x.RequiredReferenceBranch, bb => |
| 58 | + { |
| 59 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 60 | + { |
| 61 | + bbb.ToTable("Root_RequiredReferenceTrunk_RequiredReferenceBranch_CollectionLeaf"); |
| 62 | + }); |
| 63 | + }); |
| 64 | + |
| 65 | + b.OwnsMany(x => x.CollectionBranch, bb => |
| 66 | + { |
| 67 | + bb.ToTable("Root_RequiredReferenceTrunk_CollectionBranch"); |
| 68 | + |
| 69 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 70 | + { |
| 71 | + bbb.ToTable("Root_RequiredReferenceTrunk_CollectionBranch_CollectionLeaf"); |
| 72 | + }); |
| 73 | + }); |
| 74 | + }); |
| 75 | + modelBuilder.Entity<RelationshipsRootEntity>().Navigation(x => x.RequiredReferenceTrunk).IsRequired(true); |
| 76 | + |
| 77 | + modelBuilder.Entity<RelationshipsRootEntity>() |
| 78 | + .OwnsMany(x => x.CollectionTrunk, b => |
| 79 | + { |
| 80 | + b.ToTable("Root_CollectionTrunk"); |
| 81 | + |
| 82 | + b.OwnsOne(x => x.OptionalReferenceBranch, bb => |
| 83 | + { |
| 84 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 85 | + { |
| 86 | + bbb.ToTable("Root_CollectionTrunk_OptionalReferenceBranch_CollectionLeaf"); |
| 87 | + }); |
| 88 | + }); |
| 89 | + |
| 90 | + b.OwnsOne(x => x.RequiredReferenceBranch, bb => |
| 91 | + { |
| 92 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 93 | + { |
| 94 | + bbb.ToTable("Root_CollectionTrunk_RequiredReferenceBranch_CollectionLeaf"); |
| 95 | + }); |
| 96 | + }); |
| 97 | + |
| 98 | + b.OwnsMany(x => x.CollectionBranch, bb => |
| 99 | + { |
| 100 | + bb.ToTable("Root_CollectionTrunk_CollectionBranch"); |
| 101 | + |
| 102 | + bb.OwnsMany(x => x.CollectionLeaf, bbb => |
| 103 | + { |
| 104 | + bbb.ToTable("Root_CollectionTrunk_CollectionBranch_CollectionLeaf"); |
| 105 | + }); |
| 106 | + }); |
| 107 | + }); |
| 108 | + } |
| 109 | +} |
0 commit comments