You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, and let me start by saying thanks for the awesome project.
I recently integrated Audit.EntityFramework into an existing project that uses an EDMX file. It worked perfectly, except for one entity that is mapped to modification functions. After some digging, I discovered that the designer had created two EntityTypeMapping elements for the entity, one containing the MappingFragment, and the other containing the ModificationFunctionMapping. This appears to be perfectly valid inside the various EF components, but results in an InvalidOperationException ("Sequence contains more than one element.") on line 161 of EntityKeyHelper.cs.
I've managed to get around the error by merging the two EntityTypeMapping elements in the EDMX, but since the designer has a mind of it's own, I wouldn't be surprised if it puts things back to the way they were the next time the file is updated from the database.
I noticed that, at runtime, EF had merged the function mapping metadata into the EntityTypeMapping instance that contained the fragment, however the opposite was not true, so it might be possible to prevent the error by filtering out EntityTypeMapping instances that don't contain any fragments. i.e. Line 161 could be updated to:
Hi, and let me start by saying thanks for the awesome project.
I recently integrated Audit.EntityFramework into an existing project that uses an EDMX file. It worked perfectly, except for one entity that is mapped to modification functions. After some digging, I discovered that the designer had created two
EntityTypeMapping
elements for the entity, one containing theMappingFragment
, and the other containing theModificationFunctionMapping
. This appears to be perfectly valid inside the various EF components, but results in anInvalidOperationException
("Sequence contains more than one element.") on line 161 ofEntityKeyHelper.cs
.I've managed to get around the error by merging the two
EntityTypeMapping
elements in the EDMX, but since the designer has a mind of it's own, I wouldn't be surprised if it puts things back to the way they were the next time the file is updated from the database.I noticed that, at runtime, EF had merged the function mapping metadata into the
EntityTypeMapping
instance that contained the fragment, however the opposite was not true, so it might be possible to prevent the error by filtering outEntityTypeMapping
instances that don't contain any fragments. i.e. Line 161 could be updated to:Regards
Rory
The text was updated successfully, but these errors were encountered: