I don’t know why it’s is error on SaveChanges(), i search in google, some body say using EF, the database’s table such have primary key, i have this, but still error. The error message is not enough clear,it just throws System.Data.UpdateException.
The Code:
public static void AddAccount(int _acc_id,string _name)
{
dataEntities de = new dataEntities(GetEntityConn());
account acc = new account
{
account_id = _acc_id,
name = _name
};
de.AddObject("account", acc);
de.SaveChanges();
}
Solved : I found the solution, see this thread : http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/48984bd4-0921-4637-bd8f-8aa1ae9514ab
For short, don’t use int as datatype , use uniqueidentifier type.This problem will not happen on SQL Server, it only occur when using SQLCE.