TrackableEntities / trackable-entities

N-Tier Support for Entity Framework with WCF or ASP.NET Web API
http://trackableentities.github.io
MIT License
120 stars 36 forks source link

ApplyChanges throws a error #224

Open isakatirci opened 5 years ago

isakatirci commented 5 years ago

I have this error. Please help me?

System.NullReferenceException: Object reference not set to an instance of an object. at TrackableEntities.EF6.DbContextExtensions.IsComplexType(DbContext dbContext, Type entityType) at TrackableEntities.EF6.DbContextExtensions.SetEntityState(DbContext context, ITrackable item, ITrackable parent, String propertyName, EntityState state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item, ITrackable parent, ObjectVisitationHelper visitationHelper, String propertyName, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChangesOnCollectionProperties(TrackingState stateFilter, Boolean includeState, EntityNavigationProperty navProp, EntityCollectionProperty1 colProp, DbContext context, ITrackable item, ObjectVisitationHelper visitationHelper, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChangesOnProperties(DbContext context, ITrackable item, ObjectVisitationHelper visitationHelper, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item, ITrackable parent, ObjectVisitationHelper visitationHelper, String propertyName, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChangesOnProperties(DbContext context, ITrackable item, ObjectVisitationHelper visitationHelper, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item, ITrackable parent, ObjectVisitationHelper visitationHelper, String propertyName, Nullable1 state, IEnumerable1 interceptors) at TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item) at Repository.Pattern.Ef6.Repository1.Update(TEntity entity, Boolean traverseGraph) in C:\Users\isa\source\repos\Helezon.FollowMe\Helezon.FollowMe.Repository.Pattern.Ef6\Repository.cs:line 70 at Service.Pattern.Service1.Update(TEntity entity) in C:\Users\isa\source\repos\Helezon.FollowMe\Helezon.FollowMe.Service.Pattern\Service.cs:line 34 at Helezon.FollowMe.Service.CompanyImageService.Update(CompanyImage entity) in C:\Users\isa\source\repos\Helezon.FollowMe\Helezon.FollowMe.Service\CompanyImageService.cs:line 59 at Helezon.FollowMe.Service.CompanyImageService.DeleteByImageName(String imageName) in C:\Users\isa\source\repos\Helezon.FollowMe\Helezon.FollowMe.Service\CompanyImageService.cs:line 78 at Helezon.FollowMe.WebUI.Controllers.FileUploadController.DeleteFile(String file, String entitytype) in C:\Users\isa\source\repos\Helezon.FollowMe\Helezon.FollowMe.WebUI\Controllers\FileUploadController.cs:line 154 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.b9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__11_0() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>cDisplayClass11_1.b2() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>cDisplayClass7_0.b1(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>cDisplayClass3_6.b3() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>cDisplayClass3_1.b5(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<>c.b152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Controller.<>c.b__151_2(IAsyncResult asyncResult, Controller controller) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.<>c.b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End() at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

isakatirci commented 5 years ago

image

isakatirci commented 5 years ago

I fix this problem with doing debug :D image

isakatirci commented 5 years ago

The Turkish alphabet character 'I' is pain in the neck. please take precautions for this

tonysneed commented 5 years ago

@isakatirci Would you be able to open a pull request with your fix?

emperador-ming commented 5 years ago

Beware! I think ApplyChanges crushes with Dates in Cultures different from English.

[NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.] TrackableEntities.EF6.DbContextExtensions.IsComplexType(DbContext dbContext, Type entityType) +247 TrackableEntities.EF6.DbContextExtensions.SetEntityState(DbContext context, ITrackable item, ITrackable parent, String propertyName, EntityState state, IEnumerable1 interceptors) +96 TrackableEntities.EF6.DbContextExtensions.SetChanges(DbContext context, ITrackable item, EntityState state, ObjectVisitationHelper visitationHelper, ITrackable parent, String propertyName, IEnumerable1 interceptors) +1337 TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item, ITrackable parent, ObjectVisitationHelper visitationHelper, String propertyName, Nullable1 state, IEnumerable1 interceptors) +2696 TrackableEntities.EF6.DbContextExtensions.ApplyChanges(DbContext context, ITrackable item) +113 Repository.Pattern.Ef6.Repository`1.Delete(TEntity entity) +31 Registro_Jornada_Laboral.Services.d__8.MoveNext() in C:\Users\pcv\source\repos\Registro Jornada Laboral\Registro Jornada Laboral

It would be great to solve this matter.

tonysneed commented 5 years ago

Commented in #225. Would like to merge the PR but it needs to be re-done.

tomeks666 commented 4 years ago

A release would be very appreciated. I am using URF.NET and this bug forces me to keep it in old version 4.2 . I tried to get development version of TrackableEntities, but it is labeled something below 2.5.7 - and URF.NET requires 2.5.7 at least. So I am stuck with 4.2, and old CommonLocator in turn as well.