Linq insert statement inserts nothing, does not fail either
- by pietjepoeier
I am trying to insert a new account in my Acccounts table with linq. I tried using the EntityModel and Linq2Sql. I get no insert into my database nor an exception of any kind.
public static Linq2SQLDataContext dataContext {
get { return new Linq2SQLDataContext(); }
}
try {
//EntityModel
Accounts acc = Accounts.CreateAccounts(0, Voornaam, Straat, Huisnummer, Stad, Land, 15, EmailReg, Password1);
Entities.AddToAccounts(acc);
Entities.SaveChanges();
//Linq 2 SQL
Account account = new Account { City = Stad, Country = Land, EmailAddress = EmailReg, Name = Voornaam, Password = Password1, Street = Straat, StreetNr = Huisnummer, StreetNrAdd = Toevoeging, Points = 25 };
dataContext.Accounts.InsertOnSubmit(account);
var conf = dataContext.ChangeConflicts; // No changeConflicts
ChangeSet set = dataContext.GetChangeSet(); // 0 inserts, 0 updates, 0 deletes
try {
dataContext.SubmitChanges();
} catch (Exception ex) { }
} catch (EntityException ex) {
}