Q:

Entity Attempting to update incorrect table / multiple instances of IEntityChangeTracker issue

This is probably a stupid question but here I go anyways.
Some facts. 

Im using entity 6.0.0.0 according to my refs. 
Im hitting an azure sql db. 
The project is based of a mvc default template thingo.

So I'm attempting to add to table via the following code. Please note only 1 path has been attempted each time not all 3 or a combination at once.
public User(UserModel userModel)
{
    using (var db = new SqlDogContext())
    {
        // Path 1 this seem like there is a better way but throws an exception anyways
        var sillyModel = new UserModel() { Id = userModel.Id };

        db.UserLibarys.Add(new UserLib {User = sillyModel, Libary = RssLibObject});
        db.SaveChanges();

        db.UserLibarys.Add(new UserLib {User = sillyModel, Libary = KodiLibObject});
        db.SaveChanges();

        db.UserLibarys.Add(new UserLib {User = sillyModel, Libary = SoundCloudLibObject });
        db.SaveChanges();

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

        // Path 2 I guess this would be ok
        var sillyModel = new UserModel() { Id = userModel.Id };
        db.UserLibarys.Add(new UserLib { User = sillyModel, Libary = RssLibObject });
        db.UserLibarys.Add(new UserLib { User = sillyModel, Libary = KodiLibObject });
        db.UserLibarys.Add(new UserLib { User = sillyModel, Libary = SoundCloudLibObject });
        db.UserLibarys.Add(new UserLib { User = sillyModel, Libary = SpotifyBridgeObject });
        db.SaveChanges();

        // Path 3 - What i want to use..
        db.UserLibarys.Add(new UserLib { User = userModel, Libary = RssLibObject });
        db.UserLibarys.Add(new UserLib { User = userModel, Libary = KodiLibObject });
        db.UserLibarys.Add(new UserLib { User = userModel, Libary = SoundCloudLibObject });
        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 UserModel User { get; set; }
}

public class UserModel
{
    [Key, ForeignKey("ApplicationUser")]
    public string Id { get; set; }

    public virtual UserLib Libary { get; set; }
    public virtual ApplicationUser ApplicationUser { get; set; }
}

public class Lib
{
    public string Name { get; set; }
    public string Logo { get; set; }

    [Key]
    public int LibId { get; set; }

    public virtual UserLib UserLib { get; set; }
}

public class ApplicationUser : IdentityUser
{
    public virtual UserModel MyUserModel { get; set; }
    // plus some other stuff in here that seems non relavent
}

Here is where the usermodel is created
using (var db = new SqlDogContext())
{ 
     db.UserModels.Add(
        new UserModel()
        {
            Id = currentId
        }
    );

    db.SaveChanges();

    query = from b in db.UserModels
            where b.Id == currentId
            select b;
}

_CurrentUser = new User(query.First());

The end goal is to have one user for one UserModel 
One UserModel for Many UserLibaries 
And For UserLibaries to Have a foreign key to the library data base.
So I have probably made a rookie mistake but can anyone see my issue :).

A:

You are trying to set the primary key: var sillyModel = new UserModel() { Id = userModel.Id }; and then store it multiple times which you can not do. Let entity framework set the primary keys. Also note that you do not have to keep calling SaveChanges() after each operation. You can do all of your inserts and then call it one time. 

