After running this code I find no entrys in my database. I receive no errors from the code.
Does anyone know what I mite be doing wrong ?
PeopleEntities1 db = new PeopleEntities1();
Person roger = new Person()
{
age = 25,
firstname = "Roger",
lastname = "Rabbit",
location = "Canada",
job = "freelance",
};
db.AddToPeople(roger);
db.SaveChanges(true);
What is the location of your database? Make sure you are not you're copying it to your output directory everytime you run your code. I might have had a similar issue with an SQLite database which was copied to the output directory every time I run my application, which made me lose changes I had made during the previous run
First of all, SaveChanges(true)
is an obsolete method so I wouldn't recommend using it. Have you tried just using SaveChanges()
? Like in db.SaveChanges()
The closest method to SaveChanges(boolean)
is SaveChanges(SaveOptions)
which Persists all updates to the data source with the specified SaveOptions
.