forked from CirrusRedOrg/EntityFrameworkCore.Jet
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGraphUpdatesJetClientCascadeTest.cs
More file actions
41 lines (33 loc) · 1.45 KB
/
GraphUpdatesJetClientCascadeTest.cs
File metadata and controls
41 lines (33 loc) · 1.45 KB
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
// 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;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using System.Linq;
namespace EntityFrameworkCore.Jet.FunctionalTests;
#nullable disable
public class GraphUpdatesJetClientCascadeTest(GraphUpdatesJetClientCascadeTest.JetFixture fixture)
: GraphUpdatesJetTestBase<
GraphUpdatesJetClientCascadeTest.JetFixture>(fixture)
{
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());
public class JetFixture : GraphUpdatesJetFixtureBase
{
public override bool NoStoreCascades
=> true;
protected override string StoreName
=> "GraphClientCascadeUpdatesTest";
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
foreach (var foreignKey in modelBuilder.Model
.GetEntityTypes()
.SelectMany(e => e.GetDeclaredForeignKeys())
.Where(e => e.DeleteBehavior == DeleteBehavior.Cascade))
{
foreignKey.DeleteBehavior = DeleteBehavior.ClientCascade;
}
}
}
}