Hi guyz, I'm going crazy abou this, because I can't see what I'm doing wrong!!! Please help me!!!
I was developing a application using Entity Framework and storing data in a .mdf database, my code can read the data, apparently it can save too, but only apparently. I get no erros, while the program is running it act like the data was saved, I can for example save an object, dispose the context, create a new one, and then when I search my object he is there!!! But when I query the database to see the stored data there's nothing there!!! If I close the app and run it again, all data was gone! Here's a example code I wrote just to test:
using (DatabaseEntities e = new DatabaseEntities())
{
for (int i = 0; i < 50; i++)
{
User u = new User();
u.Nome = "User" + i.ToString();
e.AddToUser(u);
}
int c = e.SaveChanges(true);
List<User> us = e.User.Where<User>(x => x.ID < 50).ToList<User>();
foreach (User u in us)
Console.WriteLine("ID: " + u.ID + " Hello from " + u.Nome);
Console.ReadKey();
}
When I run this, I get the 50 outputs, if I look the content of the c variable in the debug, there's 50 changes, everythings seems to be fine, but when I start my query browser and look in the content of my MDF database, there's nothing there!!!
Probably it's something very simple but I can't see what it is, I need your help guyz!