I have .NET 8 project using MongoDB.EntityFrameworkCore v7.0.0-preview and MongoDB.Driver v2.24.0.
I created my MyDbContext class inherited from the DbContext and in the void OnModelCreating(ModelBuilder modelBuilder) method performed all required attributes mapping.
But when I called var drawings = db.Drawings.ToList(); I got the following exception:
Exception thrown:
System.Collections.Generic.KeyNotFoundExceptionin MongoDB.EntityFrameworkCore.dllAn unhandled exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in MongoDB.EntityFrameworkCore.dll The given key was not present in the dictionary.
I checked all attributes binding. For example, binding the property Name looks like below:
b.Property(c => c.Name).HasElementName("name");
How can I understand what causes the exception? I tried to analyze the callback stack. But it doesn’t help a much and the InnerException is null.
I have a few collections and they are loaded without a problem. But this one thought the exception and I can’t understand why.
Thanks