EF generates 2 EntityTypeMapping items
See original GitHub issueHello! Thank you very much for your awesome libraries!
Describe the bug For some entites I have an exception “Sequence contains more than one element.” I use Entity Framework 6.2 and code first. I noticed, that this issue happen, when I use “MapToStoredProcedures” method for the corresponding configuration entity class. But it happens for some tables/classes, and does not happen for others.
To Reproduce I am not sure, how can I reproduce this bug. I even create very simple table and entity class with 2 columns and without relationships. But when I added “MapToStoredProcedures” method, AuditLog.EntityFramework threw an excpetion on “SaveChanges” method call. The source of exception is “GetMappingFragment” method in the EntityKeyHelper class. Then I cloned the source of the libraries and debug this method. It is strange, but when I use “MapToStoredProcedures” method EF generates 2 EntityTypeMapping items for this entity. So I resolve my issue, when change line 112:
return mapping.EntityTypeMappings.Single(m => m.Fragments.Count != 0).Fragments.Single();
It is very similar on this issue: https://github.com/thepirat000/Audit.NET/issues/17
Libraries (specify the Audit.NET extensions being used including version):
- Audit.Net: 14.0.3
- Audit.EntityFramework: 14.0.3
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I have just cheked the update and it is working perfectly.
Thank you very much for quick turn around. Your support is much appreciated!