I use EF6 and I find something strange
Suppose the Client has a constructor with a parameter,
if I use new Customer(id, "name") and do
using (var db = new EfContext("name=EfSample")) { db.Customers.Add( new Customer(id, "name") ); db.SaveChanges(); }
It works without errors, but when I look into the database, I find that the data is NOT inserted,
But if I add curly braces, use new Customer(id, "name"){} and do
using (var db = new EfContext("name=EfSample")) { db.Customers.Add( new Customer(id, "name"){} ); db.SaveChanges(); }
then the data will be actually inserted,
it seems that Curly Brackets matter, I think that only when adding Curly Brackets does the entity structure recognize that this is real concrete data.
yu yang Jian Apr 07 '17 at 3:49 on 2017-04-07 03:49
source share