-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
@AndriySvyryd there seems to be an issue with ChangeTracker.DebugView.LongView and complex properties, but it may actually be a more important issue, not sure:
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
context.Blogs.Add(new Blog
{
Name = "Blog 1",
Related = new List<Related>
{
new Related { Title = "Related 1" },
new Related { Title = "Related 2" }
}
});
// This throws ArgumentOutOfRangeException internally (use first-chance exceptions etc.)
Console.WriteLine(context.ChangeTracker.DebugView.LongView);
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().ComplexCollection(b => b.Related, rrb => rrb.ToJson());
}
}
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
public List<Related> Related { get; set; }
}
public class Related
{
public int Foo { get; set; }
public string Title { get; set; }
}Exception:
at System.SZArrayHelper.get_Item[T](Int32 index)
at lambda_method52(Closure, Blog, IReadOnlyList`1)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntryBase.ReadPropertyValue(IPropertyBase propertyBase) in /Users/roji/projects/efcore/src/EFCore/ChangeTracking/Internal/InternalEntryBase.cs:line 863
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntryBase.get_Item(IPropertyBase propertyBase) in /Users/roji/projects/efcore/src/EFCore/ChangeTracking/Internal/InternalEntryBase.cs:line 1272
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntryBase.GetCurrentValue(IPropertyBase propertyBase) in /Users/roji/projects/efcore/src/EFCore/ChangeTracking/Internal/InternalEntryBase.cs:line 916
at Microsoft.EntityFrameworkCore.Update.UpdateEntryExtensions.<ToDebugString>g__DumpProperties|2_0(ITypeBase structuralType, Int32 tempIndent, <>c__DisplayClass2_0&, <>c__DisplayClass2_1&) in /Users/roji/projects/efcore/src/EFCore/Update/UpdateEntryExtensions.cs:line 119
at Microsoft.EntityFrameworkCore.Update.UpdateEntryExtensions.<ToDebugString>g__DumpProperties|2_0(ITypeBase structuralType, Int32 tempIndent, <>c__DisplayClass2_0&, <>c__DisplayClass2_1&) in /Users/roji/projects/efcore/src/EFCore/Update/UpdateEntryExtensions.cs:line 179
at Microsoft.EntityFrameworkCore.Update.UpdateEntryExtensions.ToDebugString(IUpdateEntry updateEntry, ChangeTrackerDebugStringOptions options, Int32 indent) in /Users/roji/projects/efcore/src/EFCore/Update/UpdateEntryExtensions.cs:line 110
Reactions are currently unavailable