An entity entity cannot be referenced by multiple instances of the IEntityChangeTracker interface. When saving
[HttpPost] public ActionResult Save(RegisterApplicationForm doc) { var entity = new sovadb001Entities0(); order norder = new order(); if(doc.fileNames!=null) foreach (var fileName in doc.fileNames) { //string fileName = System.IO.Path.GetFileName(UploadedFile.FileName); document ndoc = new document(); ndoc.conuntOfSymbols = 1; System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath("~/Content/Temporary/" + fileName)); ndoc.dataType =fi.Extension; ndoc.pathToDoc = fi.Directory.FullName; ndoc.order = norder; ndoc.idOrder = norder.IdOrder; //DataBase.AddDoc(ndoc); entity.documents.Add(ndoc); norder.documents.Add(ndoc); Server.MapPath("~/Content/file" + fileName).ToString(); System.IO.File.Move(Server.MapPath("~/Content/Temporary/" + fileName), Server.MapPath("~/Content/file/"+fileName)); //using (FileStream fs = new FileStream("~/Content/Temporary/" + fileName, FileMode.Open)) { // using(FileStream fsw=new FileStream("~/Content/file/"+fileName,FileMode.CreateNew)){ // ; // fs // } //} } foreach (var spec in doc.spec) { documentSpecialization ndocSpec = new documentSpecialization(); ndocSpec.order = norder; ndocSpec.IdOrder = norder.IdOrder; ndocSpec.IdSpecialization = DataBase.GetSpecialization(spec).IdSpecialization; ndocSpec.specialization = DataBase.GetSpecialization(spec); //DataBase.AddDocSpec(ndocSpec); entity.documentSpecializations.Add(ndocSpec); norder.documentSpecializations.Add(ndocSpec); } norder.dateOfCompletion = DateTime.Now; norder.name = doc.name; norder.description = doc.description; norder.idDone = false; //DataBase.AddApplication(norder); entity.orders.Add(norder); return RedirectToAction("Index","Home"); // } }' An error occurs in the entity.documentSpecializations.Add(ndocSpec); method entity.documentSpecializations.Add(ndocSpec);
System.IO.FileNotFoundException not processed by user code HResult = -2147024894 Message = File 'C: \ Users \ Oleksandr \ Documents \ Visual Studio 2012 \ Projects \ SovaTranslate_001 \ SovaTranslate_001 \ Content \ Temporary \ 1O45e0euv0o.jpg' could not be found. Source = mscorlib FileName = C: \ Users \ Oleksandr \ Documents \ Visual Studio 2012 \ Projects \ SovaTranslate_001 \ SovaTranslate_001 \ Content \ Temporary \ 1O45e0euv0o.jpg StackTrace: in System.IO .__ Error.WinIOError (Int32 errorCode, String traceFirePath)) .IO.File.InternalMove (String sourceFileName, String destFileName, Boolean checkHost) in System.IO.File.Move (String sourceFileName, String destFileName) in SovaTranslate_001.Controllers.ApplicationController. \ Documents \ Visual Studio 2012 \ Projects \ SovaTranslate_001 \ SovaTranslate_001 \ Controllers \ ApplicationController.cs: line 76 in lambda_method (Closure, ControllerBase, Object []) in System.Web.Mvc.ActionMethodDispatcher.Execute (ControllerBase controller, Object []] ) in System.Web.Mvc.ReflectedActionDescriptor.Execute (ControllerContext controllerContext, IDictionary
2 parameters) в System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) в System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) в System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() в System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.b__7 (the IAsyncResult _) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End () in System.Web.Mvc.Async AsyncResultWrapper.End [TResult] (IAsyncResult asyncResult, Object tag) in System.Web.M.c.v.yn.Async.AsyncControllerActionInvoker.isEndInvokeActionMethod (IAsyncResult asyncResult) in is iscs in ise is in. Is iscs in ise is in. Is iscs in ise is in. Is iscs in ise is in. Is iscs in is iscs in ises () in System.Web.Mvc.Async.AsyncControllerActionInvoker. <> c__DisplayClass4f.b__49 () InnerException:

tyr{} catch{}block, then post an error. - SᴇM