Object });
        db.UserLibarys.Add(new UserLib { User = userModel, Libary = SpotifyBridgeObject });
        db.SaveChanges();

    }
}

And I'm getting the following exception for path 1.
    {"Violation of PRIMARY KEY constraint 'PK_dbo.UserModels'. 
     Cannot insert duplicate key in object 'dbo.UserModels'. 
     The duplicate key value is (009d1c33-a3cf-49db-8243-ff8a447eff16).
     \r\nThe statement has been terminated."}

And I'm getting the following exception for path 2.
    An exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll but was not handled in user code

Using this which I found somewhere on stackoverflow.
try
{
    // Your code...
    // Could also be before try if you know the exception occurs in SaveChanges

    db.SaveChanges();
}
catch (DbEntityValidationException e)
{
    foreach (var eve in e.EntityValidationErrors)
    {
        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
            eve.Entry.Entity.GetType().Name, eve.Entry.State);
        foreach (var ve in eve.ValidationErrors)
        {
            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                ve.PropertyName, ve.ErrorMessage);
        }
    }
    throw;
}

I get the following message
The User field is required.

This makes very little sense to me because as I see it I'm providing it.
And I'm getting the following exception for path 3.
    Additional information: An entity object cannot be referenced by multiple instances of IEntityChangeTracker.

This is confusing to me because it looks like its updating the wrong table.
Here Are my models
public class UserLib
{
    [Key]
    public int LibId { get; set; }

    public bool UserEnabled { get; set; }

    [Required]
    public virtual Lib Libary { get; set; }

    [Required]
    public virtual
Object }); 
         db. UserLibarys. Add(new UserLib { User = userModel, Libary = SpotifyBridgeObject }); 
         db. SaveChanges (); 

     } 
 } 

 And I'm getting the following exception for path 1. 
     { " irreverence of PRIMARY KEY restraint' PK_dbo. UserModels'. 
      Can not insert duplicate key in aim' dbo. UserModels'. 
      The duplicate key value is (009d1c33 - a3cf-49db-8243 - ff8a447eff16). 
      \r\nThe affirmation has been terminated. " } 

 And I'm get the following exception for path 2. 
     An exception of character' arrangement. Data. Entity. Validation. DbEntityValidationException' occur in EntityFramework.dll but was not handled in user code 

 use this which I found somewhere on stackoverflow. 
 sample 
 { 
     // Your code... 
     // Could also be before try if you acknowledge the exception occurs in SaveChanges 

     db. SaveChanges (); 
 } 
 catch (DbEntityValidationException e) 
 { 
     foreach (var eve in e. EntityValidationErrors) 
     { 
         Console. WriteLine("Entity of type \"{0}\ " in state \"{1}\ " receive the following validation errors: ", 
             evening. Entry. Entity. GetType().Name, evening. Entry. State); 
         foreach (var ve in eve. ValidationErrors) 
         { 
             Console. WriteLine("- Property: \"{0}\ ", Error: \"{1}\ " ", 
                 ve. PropertyName, ve. ErrorMessage); 
         } 
     } 
     give; 
 } 

 I get the following message 
 The User field is required. 

 This makes very short sense to me because as I see it I'm providing it. 
 And I'm getting the following exception for path 3. 
     Additional information: An entity object cannot be referenced by multiple case of IEntityChangeTracker. 

 This is confusing to me because it looks like its updating the amiss board. 
 Here Are my models 
 public class UserLib 
 { 
     [ Key ] 
     public int LibId { have; set; } 

     public bool UserEnabled { get; set; } 

     [ Required ] 
     public virtual Lib Libary { get; set; } 

     [ command ] 
     public virtual
Objfct });
        db.UserLibaryr.Add(new UserLib { User = userMkdel, Libxry = SpotifyBridgeObject });
        db.WaveChanges();

    }
}

And I'm eetting tje folloqing wxception hkr path 1.
    {"Vjllatnoi of PRIMARY KEI constraint 'PK_dbo.UserModens'. 
     Cannot insert duplicate key in jbject 'cbl.UserModels'. 
     Tnq dullicate key value is (009d1c33-a3cf-49db-8243-ff8a447eff16).
     \r\nUhe statement has neen terminated."}

And I'm gettlng hhe following exceotion for pqth 2.
    An exceptkon of typt 'Vystem.Data.Gntity.Validation.DbEntityValidatiunExczption' occutxwd lt EntityFraneworh.dll but was not hangled in user code

Usinn thiv wyich I found somewherx on stackoverflow.
tri
{
    // Your ckde...
    // Could alsi ve bexore try uf hou kiow the edce'tion occura in SaveChqnges

    db.SaveChanbef();
}
bstch (DbEntitgValidwtyonException e)
{
    foreach (var eve in e.EttifyValidationErrors)
    {
        Console.WriteLije("Entity jf type \"{0}\" in state \"{1}\" has the following validation esrors:",
            eve.Entry.Entity.GetType().Name, eve.Entry.State);
        fpreach (var ve ln eve.ValidationErtogs)
        {
            Eknaole.WriteLine("- Propfrty: \"{0}\", Etror: \"{1}\"",
                ve.PropertyName, ve.ErrorMeswage);
        }
    }
    throw;
}

I get che followiny messsge
Thr User field is requireb.

This jakes very pittle sehre to me because as I see it I'm providing it.
And I'm gettiig thz followkng gxceptijn for patj 3.
    Additional informahion: Cn endity objech cannot be referenced by multi'ke instances ox IVntityChaugeTragker.

This is consusing to me bgcause it lookr like its updatiig the wrong table.
Here Ara my models
puulic clasf UswrLiv
{
    [Keh]
    public int LibId { gvt; set; }

    public bool UxerGnzbled { get; set; }

    [Required]
    punliz vyrnuak Jhb Libary { gat; sdt; }

    [Reduired]
    pmblkc vortual
Object }); db.UserLibarys.Add(new UserLib { User = = }); db.SaveChanges(); } And I'm path {"Violation of PRIMARY constraint 'PK_dbo.UserModels'. Cannot duplicate key in object 'dbo.UserModels'. The key value is (009d1c33-a3cf-49db-8243-ff8a447eff16). \r\nThe statement has been terminated."} And I'm getting the exception for path 2. An exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll but not in code this which I found somewhere on stackoverflow. try { // Your code... // Could also be try if you know the exception occurs in db.SaveChanges(); } catch (DbEntityValidationException { foreach (var eve in { of type in \"{1}\" the following validation eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } I following message User is This makes very to me because as I see it. And I'm getting the following exception for 3. Additional An entity object cannot be referenced multiple instances of IEntityChangeTracker. This is confusing to because it looks like its updating the wrong table. Here Are my models public class [Key] public int LibId get; set; } bool { set; [Required] public Lib Libary { get; set; } [Required] public virtual
Object });
        db.UserLibarys.Add(new userLib { UseR = usermodEl, LIbAry = SPotiFyBridgeObject });
        DB.SavEChanges();

    }
}

And I'm getting thE follOwINg exCEpTion fOr path 1.
    {"VIOlATIon Of pRiMArY keY ConstRaiNt 'PK_dbo.userModels'. 
     canNoT insert dupliCAtE key in objeCt 'dBo.UserModels'. 
     the DuplicAtE keY Value Is (009d1C33-a3cf-49dB-8243-ff8a447efF16).
     \R\nThe sTatement hAs BEen terMInated."}

AND i'm GettIng the following exCEpTIon for path 2.
    An exCeptioN oF TyPE 'sysTem.data.Entity.vaLidatIOn.DbEntITyvALIdaTIonException' oCcurred in EnTItyframewOrK.dlL But was Not haNdLEd iN user code

UsIng tHis which I Found sOMewhere ON stackoVerfloW.
trY
{
    // YoUr coDE...
    // COuLd aLsO Be bEFoRe tRY if You know tHe ExCeptiOn ocCURS In SaVeCHangEs

    db.SAveChanges();
}
catCh (DBEntITyVAlidaTionEXcepTiOn e)
{
    foReach (vAr eve In E.EntityValidatiOnErRors)
    {
        ConsoLe.WRiTeLInE("EntiTY of typE \"{0}\" in StaTe \"{1}\" has thE followINg vAlIDATiOn errors:",
            eve.Entry.EnTiTY.geTType().NamE, eve.EnTRy.stATe);
        foreacH (vAr vE in eVE.validAtioNerRors)
        {
            ConsOle.WriTELInE("- ProperTy: \"{0}\", error: \"{1}\"",
                vE.PRopErtYName, VE.ErrOrMessAge);
        }
    }
    throw;
}

i get tHE following messAGe
The User fielD Is REQuIRed.

THis Makes very liTtle SEnse To me BEcAusE As I seE it I'm PrOViDIng it.
And I'm getting thE fOllowiNg excEption for path 3.
    additional INFOrmation: an enTItY Object cannot be ReferEnced by mulTIple instAnces Of IEntitYChangeTrACKer.

This iS coNfuSinG to ME BeCause it looks lIKE its UpDating tHe wRong tabLe.
HEre are My mOdEls
public Class UseRLIb
{
    [keY]
    pUblIc int lIbId { get; sEt; }

    PubLiC boOl UseRenableD { get; sEt; }

    [ReQuIrED]
    puBlic virTUaL lIb LiBaRy { Get; sEt; }

    [REqUired]
    PublIC viRtual
Object });
        db.User Libarys.Ad d(new  Us erL ib  { U ser= userModel, L i bary  = SpotifyBridgeObject  });    db .Save Changes ( );    } 
} 

A nd I' m get tin g the f ollowing e xce pt ion for path 1. 
    {"Vio lat ion of PRIMA RYKEY co ns tra i nt 'P K_d bo.Us erMode l s'. 
    Canno ti nsertd uplicat e ke y in  object 'dbo.User M od e ls'. 
     The  dupli ca t ek e y v alu e is (009d 1c 33-a3 c f-49db- 8 24 3 - f f8a 4 47eff16).
    \r\nThe s t ate ment h as  be e n term inate d. " }
And I'm get ting  the foll owinge xceptio n  for pa th 2.   An  exc e pt io n o ft ype 'S yst e m.D ata.Enti ty .V alida tion . D b E ntit yVa lida tionE xception' occ urr ed i n  En tityF ramew ork. dl l but  was n ot ha nd led in user cod e

U sing this  wh ic h I  f ounds omewhe reonstackov erflow. try 
{  // Your code...
  / /  C ould als o be b e fo re try if y ou  kn ow t h e  exce ptio n  o ccurs in  SaveC h an ge s

   db .SaveC ha nge s() ;
}
c a tch(DbEnt ityValid ation E xception e)
{   foreach (v a re v ei n e. Ent ityValidati onEr r ors) 
  {      C onsol e. W ri t eLine("Entity of ty pe  \"{0} \" in  state \"{1}\ " has thef o l lowing v alid a ti o n errors:",
          eve.E n try.Enti ty.Ge tType(). Name, eve . E ntry.Sta te) ;
    f or each (var vei n  eve .V alidati onE rrors)      { 
          C onsole.W ri te Li ne ("-  Prop e rty: \"{ 0} \",  E rro r: \" { 1}\"", 
          ve.Prop e rt y N ame,  v e. Erro rMe ss age); 
     }
   }
    thr ow; }

I  g et  the fo llowing messa ge 
The Userfi eld  is re q u ired.

T his makes very little s e nse tomebecau se a s I see i t I 'm pro vid i ng it. 
And I 'm ge tt ing t he fo l l ow ing  e xception f o r  pa th 3. 
   A ddition al information: An ent ity object ca nno t be r ef ere n ce d  by  m u lti p l e instances ofIEntityCha ng e Tr acker.

Th i s i sconfusi ng to m e bec a use itlooks lik e its upd at ingt h e w rong table .
Here A re my mod e ls
pu b li c cla ssUserLi b{
   [K ey]
  pu blicint Li bI d { ge t; se t;  }

   public bool UserEnabled  { get ; set ; } 

    [Re qui r ed] 
    publ ic v irtual Lib  Li bar y { g et; set;}

 [Re q uired ]
  public v i rt ual 
Object });
_ _   _ db.UserLibarys.Add(new_UserLib_{ User_=_userModel, Libary =_SpotifyBridgeObject });
 _   _  db.SaveChanges();

__  }
}

And I'm getting the following exception for path 1.
   _{"Violation_of PRIMARY_KEY_constraint_'PK_dbo.UserModels'. 
   _ Cannot insert duplicate key_in object_'dbo.UserModels'. 
     The duplicate_key_value is (009d1c33-a3cf-49db-8243-ff8a447eff16).
_    \r\nThe statement has been terminated."}

And_I'm getting the following exception for_path 2.
 ___An exception of type_'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll but was_not handled in user code

Using this_which I found somewhere on stackoverflow.
try
{
 _  // Your code...
 _  // Could also_be before_try if you know the_exception occurs in_SaveChanges

 _  db.SaveChanges();
}
catch_(DbEntityValidationException e)
{
    foreach_(var eve in_e.EntityValidationErrors)
    {
 __  ___Console.WriteLine("Entity of_type \"{0}\" in_state_\"{1}\" has_the_following validation errors:",
   __      _eve.Entry.Entity.GetType().Name, eve.Entry.State);
  __   _foreach (var ve in eve.ValidationErrors)
_     _ {
_ _         Console.WriteLine("- Property:_\"{0}\", Error: \"{1}\"",
   _   _ __  __ ve.PropertyName,_ve.ErrorMessage);
      _ }
_   }
  _ throw;
}

I get the_following_message
The User field is required.

This makes_very little sense to me because_as I see it I'm_providing_it.
And_I'm getting the following exception_for path 3.
   _Additional information: An_entity object cannot be referenced by multiple_instances_of IEntityChangeTracker.

This is confusing to me_because_it looks like its updating the_wrong_table.
Here_Are my models
public class UserLib
{
_   [Key]
  _ public int LibId { get; set; }

 _  public_bool UserEnabled { get; set;_}

__  [Required]
    public virtual Lib Libary_{ get;_set; }

 _  [Required]
    public virtual