I'm getting this exception whenever a entity is modified or removed, adding new entities doesn't seem to be affected. The full stack trace looks like this:
Â
System.ArgumentNullException: Value cannot be null. (Parameter 'filter') Â at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName) at MongoDB.Driver.DeleteOneModel`1..ctor(FilterDefinition`1 filter) Â Â at MongoDB.EntityFrameworkCore.Storage.MongoUpdate.ConvertDeleted(IUpdateEntry entry) Â Â at MongoDB.EntityFrameworkCore.Storage.MongoUpdate.Create(IUpdateEntry entry) Â Â at System.Linq.Enumerable.IEnumerableSelectIterator`2.MoveNext() Â Â at System.Linq.Enumerable.OfTypeIterator`1.MoveNext() Â Â at MongoDB.EntityFrameworkCore.Storage.MongoUpdateBatch.CreateBatches(IEnumerable`1 updates)+MoveNext() Â Â at MongoDB.EntityFrameworkCore.Storage.MongoDatabaseWrapper.WriteBatchesAsync(IEnumerable`1 updates, IClientSessionHandle session, CancellationToken cancellationToken) Â Â at MongoDB.EntityFrameworkCore.Storage.MongoDatabaseWrapper.SaveChangesAsync(IList`1 entries, CancellationToken cancellationToken) Â Â at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) Â Â at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) Â Â at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
I'm wondering if it's due to me using a shadow property as the primary key, but this was working at one point and I've not updated any EF or Mongo related packages.
public void Configure(EntityTypeBuilder<Entity> builder)Â Â { Â Â Â Â builder.ToCollection(Collection); Â Â Â Â builder.Property<ObjectId>("Id"); Â Â Â Â builder.HasKey("Id"); Â Â Â Â builder.Property(x => x.Date).HasBsonRepresentation(BsonType.DateTime); Â Â Â Â builder.HasIndex(x => new { x.AccountId, x.Date }).IsUnique().IsDescending(); }
Â
Â