Change AuditStateEntry's EntityType so that it returns the correct underlying EntityType #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Entities that inherit from a base entity are not having their changed properties written to the audit log.
I believe the source of the problem lies with the way EntityType of an entity is being retrieved from the ObjectContext.
For example given the following Code First model:
If you try to retrieve the EntityType of Car with the following line of code in
EntityFramework.Audit.AuditEntryState line 23EntityType = objectStateEntry.EntitySet.ElementType as EntityType;The EntityType returned becomes Vehicle and not Car.
Later on in
EntityFramework.Audit.AuditLogger line 227when you compare the modified properties of Car usingvar properties = state.EntityType.Propertiesit would only give you a VehicleID and NumWheels off of the Vechicle.This pull request modifies the EntityType retrieval strategy so that it will return the underlying EntityType of an entity that inherits from an abstract base entity which hopefully allows accurate modified properties comparison.