c# - "Invalid Object Name" error during db.SaveChanges() (Entity Framework/MVC) -


(solved)

i getting strange error when trying save changes entity app building.

    [httppost]     [validateantiforgerytoken]     public actionresult edit([bind(include = "reportid,recordid,reportname,filename,reporttypeid,owningapplicationid,recordcid,assigneduserid")] report report)     {         if (modelstate.isvalid)         {             db.entry(report).state = entitystate.modified;             db.savechanges();             return redirecttoaction("index");         }         viewbag.owningapplicationid = new selectlist(db.applications, "applicationid", "applicationname", report.owningapplicationid);         viewbag.reporttypeid = new selectlist(db.reporttypes, "reporttypeid", "reporttypetext", report.reporttypeid);         return view(report);     } 

at db.savechanges() following error:

an exception of type 'system.data.entity.infrastructure.dbupdateexception' occurred in entityframework.dll not handled in user code

if examine inner exceptions find this:

"invalid object name 'tg_datacleaningmaintenance_pendinginsert__20150709_000000_953cccd7-0ba4-4b3e-ae5d-df6b936841f8'."

the exception occurs here:

at system.data.entity.core.mapping.update.internal.updatetranslator.update() @ system.data.entity.core.entityclient.internal.entityadapter.<update>b__2(updatetranslator ut) @ system.data.entity.core.entityclient.internal.entityadapter.update[t](t nochangesresult, func'2 updatefunction) @ system.data.entity.core.entityclient.internal.entityadapter.update() @ system.data.entity.core.objects.objectcontext.<savechangestostore>b__35() @ system.data.entity.core.objects.objectcontext.executeintransaction[t](func'1 func, idbexecutionstrategy executionstrategy, boolean startlocaltransaction, boolean releaseconnectiononsuccess) @ system.data.entity.core.objects.objectcontext.savechangestostore(saveoptions options, idbexecutionstrategy executionstrategy, boolean startlocaltransaction) @ system.data.entity.core.objects.objectcontext.<>c__displayclass2a.<savechangesinternal>b__27()

i cannot find online datacleaningmaintenance_pendinginsert or similar. remember seeing table similar name in database on week ago, has since been deleted.

i have updated model database, rebuilt project, scoured project reference table, verified table not exist in database. examine db object during debugging , can't find reference object, , have verified connection string correct , includes database name (not server name). have no idea how approach problem @ point. please help!

thanks!

edit: there indeed trigger set on report table in sql server, causing server reject update above message. trigger appears have come ssis package used fuzzylookup on table. deleting trigger should fix problem.

solved user br4d!

there trigger on report table in sql server, left on ssis package used fuzzylookup on table. i'm unsure how missed checked triggers in ssms. used query find it:

select * (   select object_name(object_id) obj,   schema_name(schema_id) [schema],   object_name(parent_object_id) parent,   type_desc obj_type   sys.objects ) objects obj 'tg_%' 

saw trigger on report, double checked triggers folder , lo , behold, there was. looking tg_datacleaning_xxx table on insert, update, , delete queries. deleted , no longer had problems.

there no problem in application code after all.


Comments