diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs index 17e3fa07584..6ff782b8cff 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs @@ -216,6 +216,47 @@ public class LazyPropertyEntity public LazyConstructorEntity LazyConstructorEntity { get; set; } } + [ConditionalFact] + public void Lazy_loading_proxies() + => Test( + new LazyLoadingProxiesContext(), + new CompiledModelCodeGenerationOptions(), + assertModel: model => + { + Assert.Equal( + typeof(ILazyLoader), model.FindEntityType(typeof(LazyProxiesEntity1))!.GetServiceProperties().Single().ClrType); + Assert.Equal( + typeof(ILazyLoader), model.FindEntityType(typeof(LazyProxiesEntity1))!.GetServiceProperties().Single().ClrType); + }); + + public class LazyLoadingProxiesContext : ContextBase + { + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(); + } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => base.OnConfiguring(options.UseLazyLoadingProxies()); + } + + public class LazyProxiesEntity1 + { + public int Id { get; set; } + + public virtual LazyProxiesEntity2 ReferenceNavigation { get; set; } + } + + public class LazyProxiesEntity2 + { + public ILazyLoader Loader { get; set; } + + public int Id { get; set; } + public virtual ICollection CollectionNavigation { get; set; } + } + [ConditionalFact] public void Throws_for_query_filter() => Test( @@ -4776,6 +4817,7 @@ protected void Test( BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Cosmos"), BuildReference.ByName("Microsoft.EntityFrameworkCore.InMemory"), + BuildReference.ByName("Microsoft.EntityFrameworkCore.Proxies"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Sqlite"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite"),