How can i insert object twice in database with different value
when the object User
has Code > 10
then it insert 2 object but some how EF update the value of the first inserted object.
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public int Code { get; set; }
}
and in my action i'm saving to databse
// Post Action
uow.Users.Add(user);
uow.Commit(); // save first time
if (user.Code > 10)
{
user.Name = "NAS";
uow.Users.Add(user);
uow.Commit(); //save second time
}
My object is
User = (Name = "Mike",Code=12)
Database result is
Result Database
id =1 Name="NAS" Code=12
id =2 Name="NAS" Code=12