-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
ManyToManyTrackingProxySqlServerTest.cs
82 lines (65 loc) · 3.98 KB
/
ManyToManyTrackingProxySqlServerTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel;
namespace Microsoft.EntityFrameworkCore;
#nullable disable
public class ManyToManyTrackingProxySqlServerTest(ManyToManyTrackingProxySqlServerTest.ManyToManyTrackingProxySqlServerFixture fixture)
: ManyToManyTrackingSqlServerTestBase<ManyToManyTrackingProxySqlServerTest.ManyToManyTrackingProxySqlServerFixture>(fixture)
{
protected override Dictionary<string, DeleteBehavior> CustomDeleteBehaviors { get; } = new()
{
{ "EntityBranch.RootSkipShared", DeleteBehavior.ClientCascade },
{ "EntityBranch2.Leaf2SkipShared", DeleteBehavior.ClientCascade },
{ "EntityBranch2.SelfSkipSharedLeft", DeleteBehavior.Restrict },
{ "EntityBranch2.SelfSkipSharedRight", DeleteBehavior.Restrict },
{ "EntityOne.SelfSkipPayloadLeft", DeleteBehavior.ClientCascade },
{ "EntityTwo.SelfSkipSharedLeft", DeleteBehavior.ClientCascade },
{ "EntityTableSharing1.TableSharing2Shared", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityBranch.UnidirectionalEntityRoot", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityOne.SelfSkipPayloadLeft", DeleteBehavior.ClientCascade },
{ "UnidirectionalEntityTwo.SelfSkipSharedRight", DeleteBehavior.ClientCascade }
};
public override Task Can_insert_many_to_many_shared_with_payload(bool async)
// Mutable properties aren't proxyable on Dictionary
=> Task.CompletedTask;
public override Task Can_update_many_to_many_shared_with_payload()
// Mutable properties aren't proxyable on Dictionary
=> Task.CompletedTask;
public override Task Can_insert_update_delete_shared_type_entity_type()
// Mutable properties aren't proxyable on Dictionary
=> Task.CompletedTask;
public override Task Can_insert_many_to_many_shared_with_payload_unidirectional(bool async)
// Mutable properties aren't proxyable on Dictionary
=> Task.CompletedTask;
public override Task Can_update_many_to_many_shared_with_payload_unidirectional()
// Mutable properties aren't proxyable on Dictionary
=> Task.CompletedTask;
protected override bool RequiresDetectChanges
=> false;
public class ManyToManyTrackingProxySqlServerFixture : ManyToManyTrackingSqlServerFixtureBase
{
protected override string StoreName
=> "ManyToManyTrackingProxies";
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(builder).UseChangeTrackingProxies();
protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
=> base.AddServices(serviceCollection.AddEntityFrameworkProxies());
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
modelBuilder.Entity<EntityBranch2>()
.HasMany(e => e.SelfSkipSharedLeft)
.WithMany(e => e.SelfSkipSharedRight)
.UsingEntity<Dictionary<string, object>>(
"EntityBranch2EntityBranch2",
r => r.HasOne<EntityBranch2>().WithMany().HasForeignKey("SelfSkipSharedRightId").OnDelete(DeleteBehavior.Restrict),
l => l.HasOne<EntityBranch2>().WithMany().HasForeignKey("SelfSkipSharedLeftId").OnDelete(DeleteBehavior.Restrict));
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
.Ignore("Payload"); // Mutable properties aren't proxyable on Dictionary
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("UnidirectionalJoinOneToThreePayloadFullShared")
.Ignore("Payload"); // Mutable properties aren't proxyable on Dictionary
}
}
}