-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
SqlServerOnDeleteConventionTest.cs
41 lines (33 loc) · 1.41 KB
/
SqlServerOnDeleteConventionTest.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;
public class SqlServerOnDeleteConventionTest
{
[ConditionalFact] // Issue #32732
public void Convention_does_not_assume_skip_navigations_have_non_null_FK()
{
using var context = new SkippyDbContext();
var model = context.Model;
Assert.Equal(["ArenaPropensity", "Arena", "Propensity"], model.GetEntityTypes().Select(e => e.ShortName()));
Assert.Equal(
[DeleteBehavior.Cascade, DeleteBehavior.ClientCascade],
model.GetEntityTypes().Single(e => e.ShortName() == "ArenaPropensity").GetForeignKeys().Select(k => k.DeleteBehavior));
}
public class SkippyDbContext : DbContext
{
public DbSet<Arena> Areas { get; private set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer();
}
public class Arena : Propensity
{
public virtual ICollection<Propensity> AreaProperties { get; set; }
}
public abstract class Propensity
{
public int Id { get; set; }
public int? PrimaryYId { get; set; }
public virtual Propensity PrimaryYProp { get; set; }
public virtual ICollection<Arena> PropertyAreas { get; set; }
}
}