diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index 93082361df9..1ec0088086d 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -2010,6 +2010,18 @@ public virtual void Lazy_loading_shares_service__property_on_derived_types() entity.BaseNoses.Select(b => b.Size).OrderBy(h => h)); } + [ConditionalFact] + public virtual void Lazy_loading_handles_shadow_nullable_GUID_FK_in_TPH_model() + { + using var context = CreateContext(lazyLoadingEnabled: true); + + var tribes = context.Set().ToList(); + + Assert.Single(tribes); + Assert.IsAssignableFrom(tribes[0]); + Assert.Equal(new DateTime(1973, 9, 3), ((Quest)tribes[0]).Birthday); + } + [ConditionalFact] public virtual void Lazy_loading_finds_correct_entity_type_with_alternate_model() { @@ -2314,6 +2326,8 @@ public class Company : Entity public class Parson : Entity { + public DateTime Birthday { set; get; } + public virtual ICollection ParsonNoses { get; set; } } @@ -2322,6 +2336,22 @@ public class Host public string HostName { get; set; } } + public abstract class Tribe + { + public Guid Id { get; set; } + } + + public class Called : Tribe + { + public string Name { set; get; } + } + + public class Quest : Tribe + { + public DateTime Birthday { set; get; } + public virtual Called Called { set; get; } + } + protected DbContext CreateContext(bool lazyLoadingEnabled = false) { var context = Fixture.CreateContext(); @@ -2375,6 +2405,10 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); modelBuilder.Entity(); modelBuilder.Entity(); @@ -2516,6 +2550,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(DbContext context) { + context.Add(new Quest { Birthday = new DateTime(1973, 9, 3) }); + context.Add( new Parent {