bilal-fazlani / tracker-enabled-dbcontext

Tracker-enabled DbContext offers you to implement full auditing in your database
https://tracker-enabled-dbcontext.bilal-fazlani.com/
Other
217 stars 110 forks source link

Given key was not present in the dictionary #154

Closed attrib75 closed 4 years ago

attrib75 commented 7 years ago

This occurs now whenever I save anything, if I do not set GlobalTrackingConfig.Enabled = false;. If i do set GlobalTrackingConfig.Enabled = false, nothing is tracked

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at EntityFramework.MappingAPI.Mappers.MapperBase.BindForeignKeys() in c:\dev\EntityFramework.MappingAPI\trunk\src\EntityFramework.MappingAPI\Mappers\MapperBase.cs:line 618 at EntityFramework.MappingAPI.Mappings.DbMapping..ctor(DbContext context) in c:\dev\EntityFramework.MappingAPI\trunk\src\EntityFramework.MappingAPI\Mappings\DbMapping.cs:line 103 at EntityFramework.MappingAPI.EfMap.Get(DbContext context) in c:\dev\EntityFramework.MappingAPI\trunk\src\EntityFramework.MappingAPI\EfMap.cs:line 60 at EntityFramework.MappingAPI.Extensions.MappingApiExtensions.Db(DbContext ctx, Type type) in c:\dev\EntityFramework.MappingAPI\trunk\src\EntityFramework.MappingAPI\Extensions\MappingApiExtensions.cs:line 51 at TrackerEnabledDbContext.Common.Configuration.DbMapping..ctor(ITrackerContext context, Type entityType) at TrackerEnabledDbContext.Common.Auditors.LogAuditor.CreateLogRecord(Object userName, EventType eventType, ITrackerContext context, ExpandoObject metadata) at TrackerEnabledDbContext.Common.CoreTracker.AuditAdditions(Object userName, IEnumerable1 addedEntries, ExpandoObject metadata) at CallSite.Target(Closure , CallSite , CoreTracker , Object , IEnumerable`1 , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at TrackerEnabledDbContext.TrackerContext.SaveChanges(Object userName)

bilal-fazlani commented 7 years ago

Could you please show how ur model looks like.

attrib75 commented 7 years ago

Hi, thanks for responding. We actually moved to another library.