MongoFramework
MongoFramework copied to clipboard
NullReference in DetectChanges
I've been using this library for a couple of days and sometimes get a NullReference error when callling SaveChangesAsync.
at MongoFramework.Infrastructure.EntityEntryContainer.DetectChanges()
Looking into this method I see EntryLookupByType.Values has 2 values with the first being null which is throwing the exception.
How can I prevent this?
That is very strange - not sure why there would be a null entry there. There should only be two code paths that add items and those items should only be added by the code here:
https://github.com/TurnerSoftware/MongoFramework/blob/bc0ce2ff7fd59eb279c7e344f89105bfeb72e89e/src/MongoFramework/Infrastructure/EntityEntryContainer.cs#L108-L119
Are you by chance sharing an instance of a MongoDbContext across threads?