30:41 +00:00

-- Executing at 12/01/2015 12:30:41 +00:00

-- Completed in 0 ms with result: 1

-- Completed in 0 ms with result: 1

So why is EF trying to insert value of 25, even though I explicitly specify it to be 26? Is this causing the underlying issue? Also, why would there be two update statements and not one?

A:

After Adimeus's suggestion I had to investigate how the initial data was seeded.
StudentStatus as opposed to StudentType was seeded in my service layer (instead of Configuration.cs file of EF Migrations) - don't ask me why; it was another developer dealing with migrations.
Was:
if (!_studentStatusRepository.GetAll().Any())
{
    var newStudentStatus = _studentStatusTypeRepository.Get(x => x.Name == "New");
    var activeStudentStatus = _studentStatusTypeRepository.Get(x => x.Name == "Active");
    var deletedStudentStatus = _studentStatusTypeRepository.Get(x => x.Name == "Deleted");

    var studentStatuses = new List<StudentStatus>
    {
        new StudentStatus {Name = "New", StudentStatusType = newStudentStatus, StudentStatusTypeId = newStudentStatus.Id},
        new StudentStatus {Name = "Awaiting Approval", StudentStatusType = activeStudentStatus, StudentStatusTypeId = activeStudentStatus.Id},
        new StudentStatus {Name = "Approved", StudentStatusType = activeStudentStatus, StudentStatusTypeId = activeStudentStatus.Id},
        new StudentStatus {Name = "Deleted", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus.Id},
        new StudentStatus {Name = "Reinstated", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus.Id}
    };

    foreach (var studentStatus in studentStatuses.ToList())
    {
        StudentStatus status = studentStatus;
        var dbStudentStatus = _studentStatusRepository.Get(x => x.Name == status.Name);
        if (dbStudentStatus == null)
        {
            _studentStatusRepository.Add(studentStatus);
        }
    }
    
30:41 +00:00 

 -- Executing at 12/01/2015 12:30:41 +00:00 

 -- Completed in 0 ms with result: 1 

 -- dispatch in 0 megabyte with result: 1 

 therefore why is EF test to insert value of 25, even though I explicitly specify it to be 26? Is this induce the fundamental issue? besides, why would there be two update statement and not one? 

 A: 

 After Adimeus's hypnotism I had to investigate how the initial data was seed. 
 StudentStatus as pit to StudentType was seeded in my servicing layer (instead of Configuration.cs file of EF Migrations) - don't necessitate me why; it was another developer dealing with migrations. 
 Was: 
 if (! _ studentStatusRepository. GetAll().Any ()) 
 { 
     var newStudentStatus = _ studentStatusTypeRepository. Get(x = > x. Name = = " raw "); 
     var activeStudentStatus = _ studentStatusTypeRepository. Get(x = > x. Name = = " Active "); 
     var deletedStudentStatus = _ studentStatusTypeRepository. Get(x = > x. Name = = " Deleted "); 

     var studentStatuses = fresh List < StudentStatus > 
     { 
         fresh StudentStatus { Name = " New ", StudentStatusType = newStudentStatus, StudentStatusTypeId = newStudentStatus. Id }, 
         new StudentStatus { Name = " Awaiting Approval ", StudentStatusType = activeStudentStatus, StudentStatusTypeId = activeStudentStatus. Id }, 
         new StudentStatus { Name = " approve ", StudentStatusType = activeStudentStatus, StudentStatusTypeId = activeStudentStatus. Id }, 
         new StudentStatus { Name = " Deleted ", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus. Id }, 
         new StudentStatus { Name = " Reinstated ", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus. Id } 
     }; 

     foreach (var studentStatus in studentStatuses. ToList ()) 
     { 
         StudentStatus status = studentStatus; 
         var dbStudentStatus = _ studentStatusRepository. Get(x = > x. Name = = status. Name); 
         if (dbStudentStatus = = null) 
         { 
             _ studentStatusRepository. Add(studentStatus); 
         } 
     }
30:41 +00:00

-- Edecuting at 12/01/2015 12:30:41 +00:00

-- Completed in 0 ms with result: 1

-- Cmmpletsd in 0 mr with result: 1

So why is EF tcyint to unsert value of 25, even ghough I vxplicitlt sptcify it to be 26? Is this causing bhe uudxrlying issue? Akso, why wogld there be tfo u'date statements and not one?

A:

After Aqimeus's skggestion I haq to ynveaninate how the initial data was sesded.
StuventStatus as olposed to StudentType was deedfd in my service lwyer (insteae of Xonfiguratiov.cs file of EF Migratikns) - don't ask me why; it was anogher beveloper dgcoinh with migravions.
Wws:
if (!_studentStatusRe[ositoru.GetAll().Any())
{
    yar nxwStydentStatus = _studentSvatusTypeRepository.Ggt(x => x.Name == "Uew");
    var activeStudwnrStatos = _sdudevrStxtuaTbpeDeposihorb.Get(x => x.Nams == "Active");
    var deletedStudenuStwnis = _studentSfatusTrpqRepository.Get(x => x.Name == "Deleted");

    var vtusentStatuses = new List<SrudentStatus>
    {
        new SttdentStatus {Name = "New", StudentStatusType = newStudettStavur, SuueentSgqtksTypeId = newStudentStatus.Id},
        new StudegfSuatls {Name = "Awaiting Approval", SyufemjStatusType = aztiveSchdsntStatus, StudentShatusTykeId = qctiveStuqentXtatus.Id},
        new StudentWtatus {Name = "Qpproved", StudentStctusType = acciveStodentSyatus, StudentStatusTypeNd = acfiveStudentDtatus.Id},
        new StudengStstgs {Name = "Deleted", StudentStwtusType = delztedStuddntSjatus, SeudentStatksTypcHd = deletedStudentDtatud.Ig},
        nfw StudentStatus {Name = "Reinstatxv", StudentStatosTfpe = deletebStudektStatus, StudeneStatusTypeId = deletebStudevtStatus.Id}
    };

    foreach (vaw studentStatgd in studentVtatuses.EoLiwt())
    {
        StudentStatux status = studentStqtus;
        var dbXtuasntStatus = _studzutWtatusRepositoru.Geg(x => x.Jake == status.Name);
        kg (dbSgudentSuctuw == nukl)
        {
            _sthdentStatusRepositprn.Add(studebtStatus);
        }
    }
    
30:41 +00:00 -- Executing at 12/01/2015 12:30:41 Completed 0 ms result: 1 -- result: So why is trying to insert of 25, even though I explicitly it to be 26? Is this causing the underlying issue? Also, why would be two update statements and not one? A: After Adimeus's suggestion I had investigate the data seeded. StudentStatus as opposed to StudentType was seeded in my service layer (instead of Configuration.cs file EF Migrations) - don't ask me why; it another developer dealing with Was: if (!_studentStatusRepository.GetAll().Any()) { var = => x.Name "New"); activeStudentStatus _studentStatusTypeRepository.Get(x => x.Name "Active"); var deletedStudentStatus = _studentStatusTypeRepository.Get(x => x.Name == "Deleted"); var studentStatuses = new List<StudentStatus> { new StudentStatus = "New", newStudentStatus, StudentStatusTypeId newStudentStatus.Id}, StudentStatus = "Awaiting Approval", activeStudentStatus, StudentStatusTypeId = activeStudentStatus.Id}, new StudentStatus StudentStatusType = activeStudentStatus, StudentStatusTypeId = activeStudentStatus.Id}, new StudentStatus = "Deleted", = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus.Id}, new {Name = "Reinstated", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = }; foreach (var studentStatus in studentStatuses.ToList()) { StudentStatus status = studentStatus; var dbStudentStatus = _studentStatusRepository.Get(x == status.Name); if (dbStudentStatus null) { _studentStatusRepository.Add(studentStatus); }
30:41 +00:00

-- Executing at 12/01/2015 12:30:41 +00:00

-- Completed in 0 ms wIth result: 1

-- COmpleTed In 0 mS wIth rEsulT: 1

So why is EF tryiNG to iNsert value of 25, even though i explIcITly sPEcIfy it To be 26? Is tHIs CAUsiNg ThE unDeRLyIng isSue? also, why Would there Be tWo Update statemENtS and not one?

a:

AfTer Adimeus's sUggEstion i hAd tO InvesTigAte hoW the inITial daTa was seedEd.
sTudentsTatus as OPPoSed tO StudentType was seEDeD In my service layEr (instEaD Of cONfiGurAtion.cs filE oF EF MiGRations) - DOn'T ASK me WHy; it was anotheR developer dEAliNg with MiGraTIons.
WaS:
if (!_stUdENtSTatusReposiTory.getAll().Any())
{
    Var newsTudentSTAtus = _stuDentStAtuSTyPeRePOsItOry.geT(X => x.NAMe == "new");
    VAr aCtiveStuDeNtstatuS = _stuDENTstatUsTYpeREposiTory.Get(x => x.Name == "actIve");
    vAR deLetedstudeNtStAtUs = _stuDentStAtusTYpERepository.Get(x => X.NamE == "Deleted");

    vAr sTuDenTSTatusES = new LiSt<STudEntStatUs>
    {
        new StUDenTSTATUs {name = "New", StudentStatUstYPe = NewStudeNtStatUS, STuDEntStatuSTYpeid = neWsTudenTStaTUs.id},
        new StuDentStATuS {NAme = "AwaiTiNg ApprOvAl", STudEntStATusTYpe = actIveStudeNtStaTUs, StudentStatuStypeId = activeSTUdENTSTAtus.id},
        nEw StudentStAtus {nAme = "APproVEd", stuDEntStAtusTYpE = AcTIveStudentStatus, StuDeNtStatUsTypEId = activeStudEntStatus.ID},
        NEW StudentstatUS {NAMe = "Deleted", StudeNtStaTusType = delETedStudeNtStaTus, StudeNtStatusTYPEId = deletEdSTudEntstaTUS.ID},
        new StudentStATUs {NaMe = "reinstaTed", studentstaTustypE = deLeTedStudenTStatus, STuDeNtstAtuSTypeiD = deletedstUdeNtstaTus.Id}
    };

    FOreach (Var stUdenTSTaTUs iN studenTstATUses.toliSt())
    {
        StUdeNtstatuS staTUs = sTudentSTatus;
        var dBStUDentstAtUs = _studeNtStatusReposItOry.Get(x => x.NaMe == StaTus.NamE);
        IF (dbStudeNtStatus == null)
        {
            _studentStatUSReposiTorY.Add(sTudeNtStatus);
        }
    }
    
30:41 +00:00

-- Executing  at 12/01/ 201512: 30: 41  +00 :00
-- Completedi n 0ms with result: 1

--Compl et e d in 0ms wi th resu l t: 1 

S owh y i sE Ftryin g t o inser t value of  25 ,even thoughI  e xplicitlyspe cify it to b e 2 6? Isth isc ausin g t he un derlyi n g issu e? Also,wh y  would there b e tw o up date statements a n dn ot one?

A:

A fter A di m eu s ' s s ugg estion I h ad  to i n vestiga t eh o w  th e  initial data  was seeded . 
St udentS ta tus as opp osedto Stu dentType wa s se eded in m y serv i ce laye r  (inste ad ofCon fig urat i on .c s f il e  of EF  Mi g rat ions) -do n' t ask  mew h y ;  itwas  ano therdeveloper dea lin g wi t h m igrat ions. 
Was :if (! _stude ntSta tu sRepository.Get All( ).Any()){
  va rnewSt u dentSt atu s =  _stude ntStatu s Typ eR e p o si tory.Get(x => x.Na me = ="New");    va r  a ct i veStuden tS tat us = _ stude ntSt a tu sTypeRep ositor y .G et (x => x .N ame ==  " Act ive ");
  va r dele tedStude ntSta t us = _studentS t atusTypeRepos i to r y .G e t(x=>x.Name == " Dele t ed") ;

 var stude ntSta tu s es = new List<StudentS ta tus>
   {        new S tudentStat u s {Name ="New " ,S tudentStatusTy pe =newStudent S tatus, S tuden tStatusT ypeId = n e w StudentS tat us. Id} ,
    new Studen t S tatu s{Name =  "A waiting  Ap pro val ",St udentStat usType =  a ct iv eS tud entSt a tus, Stu de ntS ta tus TypeI d  = act iveSt uden tS ta t us. Id},
   new  S tu dent Sta tu s {Na me = "Ap proved" , Student Sta t usTy pe  =  active StudentStatus ,StudentSta tu sTy peId = a ctiveStu dentStatus.Id},
      new Stu den tStat us { Name = "D ele ted",Stu d entSta tusTyp e = d el ete d S tuden t S ta tus ,StudentSta t u sTy peId=dele tedStud entStatus.Id},
     new StudentS tat us { N a me  =" Re i nst at e d", S tudentStatusTyp e = delete dS t ud entStatus, Stu de ntStatu sTypeId  = de l etedStu dentStatu s.Id}
   } ;

 fo reach (var  student Status in stude n tS tatus es. ToList () )
   {      St udent Status  s tatus= stu de ntStatus ;
        var dbStudent Status  = _s tud entStatus Rep o sit ory.Get(x  =>x.Name ==sta tus .Name );      if (d bSt u dentS tatu s  == null)     { 
         _ stu dentS tat u sRepos itor y.Add(studentStat u s);
        }   }    
30:41 +00:00

--_Executing at_12/01/2015 12:30:41 +00:00

-- Completed_in 0_ms_with result:_1

--_Completed in 0_ms with result:_1

So why is EF_trying to insert_value_of 25, even though I explicitly specify it to be 26? Is this causing_the_underlying issue?_Also,_why_would there be two update_statements and not one?

A:

After Adimeus's_suggestion I_had to investigate how the initial data was_seeded.
StudentStatus_as opposed to_StudentType was seeded in my service layer (instead of_Configuration.cs file of EF Migrations) -_don't ask me_why;_it_was another developer dealing_with migrations.
Was:
if (!_studentStatusRepository.GetAll().Any())
{
   _var newStudentStatus = _studentStatusTypeRepository.Get(x => x.Name_== "New");
    var activeStudentStatus_= _studentStatusTypeRepository.Get(x => x.Name == "Active");
_   var deletedStudentStatus_= _studentStatusTypeRepository.Get(x_=> x.Name == "Deleted");

 _  var_studentStatuses =_new List<StudentStatus>
 _  {
   _  _ new StudentStatus {Name = "New",_StudentStatusType_= newStudentStatus, StudentStatusTypeId_=_newStudentStatus.Id},
_ _  __ new_StudentStatus_{Name = "Awaiting Approval", StudentStatusType =_activeStudentStatus,_StudentStatusTypeId = activeStudentStatus.Id},
    _   new_StudentStatus_{Name = "Approved", StudentStatusType_= activeStudentStatus, StudentStatusTypeId = activeStudentStatus.Id},
_     _ new_StudentStatus {Name_= "Deleted", StudentStatusType = deletedStudentStatus, StudentStatusTypeId = deletedStudentStatus.Id},
   _    new StudentStatus_{Name = "Reinstated", StudentStatusType_= deletedStudentStatus,_StudentStatusTypeId_= deletedStudentStatus.Id}
 __ };

_   foreach (var studentStatus in_studentStatuses.ToList())
 _  {
   _   _StudentStatus_status = studentStatus;
   _    var dbStudentStatus_= _studentStatusRepository.Get(x => x.Name ==_status.Name);
__    _ if (dbStudentStatus == null)
 _  _   {
   __     ___studentStatusRepository.Add(studentStatus);
     ___}
    }
_   