Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-106

Cannot suppress saving of fields with default values

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: Public Preview 1
    • Dotnet Drivers

      I want to use EF Core to save an object and suppress saving of all the fields that has default values. This works just fine (as in properties with null/default values don't get saved to MongoDB) with configuring BsonClassMap (using explicit configuration in code rather than attributes, but attributes also works) and saving the objects with coll.InsertOne.

      However when saving the same object with EF Core

              var db = StarGateDbContext.Create(client.GetDatabase("Sinelec"));
              // Create
              db.Add(transit);
              db.SaveChanges(); 

      all properties are saved, default values or not. Adding the [DataMember(EmitDefaultValue=false)] makes no difference.

      Not sure if this is just something that's not yet implemented or if it is a de-facto bug.

       

            Assignee:
            damien.guard@mongodb.com Damien Guard
            Reporter:
            magnus.strale@mongodb.com Magnus Strale
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: