I’m trying to insert something into a local database, but it doesn’t work..
ModelContainer mc;
public DBController()
{
mc = new ModelContainer();
}
public void SaveArtikel(string name)
{
mc.Connection.Open();
int id = mc.Produkt.ToList().Last().ID + 1;
mc.Produkt.AddObject(new Produkt() { ID = id, Name = name });
mc.SaveChanges();
mc.Connection.Close();
}
That’s how i tryed it. (It’s mixed with german words..)
After that i have access on the articel but it isn’t in the database..
EDIT:
The db is an .sdf file.
I right clicked on the project and then i pressed on “new item”. There i searched for “Local Database” (Compact Server)
Well, i think it worked all the time..
I published the project to see how it works there. After many tests it looked very good. Even after I restarted the pc the data were in the db.
I don’t know why i can’t see the data manually.. but that’s no problem.
Thanks to all who helped me!