Support shadow properties in keys

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Unknown
    • 9.0.1, 8.3.1
    • Affects Version/s: None
    • None
    • 🔵 Done
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      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();
      } 

       

       

            Assignee:
            Damien Guard
            Reporter:
            James Dibble
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: