InvalidOperationException updating an entity with CurrentValues.SetValues throws InvalidOperationException when the SetValues parameter does not contain a required field data. #8465
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
I am writing a custom save generic method for our framework in EF Core. The idea is to have a method that can make partial updates
The method is working with simple entities but throws an InvalidOperationException when the entity in entitiesAndProperties does not contain a required field data. It should not be a problem, because the entity already exists in database with the required field value, contextEntity reflects that, but seems the CurrentValues.SetValues overrides this.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
Those are the custom entity method and clases.
If I change the code to this, it is working properly, but it uses reflection, and not seems that Smart as SetValues. With the SetValues documentation I thought that I could do what I did before... I thought that the ChangeTracker only updated the IsModified properties...
This is the reproducing code. It seems that it is simple to reproduce, but if you really need i could try to make a simple .NET Core console app which reproduces this.
Further technical details
EF Core version: 1.1.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServe
Operating system:
IDE: Visual Studio 2017 15.2
The text was updated successfully, but these errors were encountered: