0

I have entity model created in Visual Studio 2010.This is part of my code:

Database1Entities1 de = new Database1Entities1();
UserInfo ui = new UserInfo();
ui.Name = "xxx";
ui.Username = "xxx";
ui.Password = "xxx";
de.UserInfoes.AddObject(ui);

It executes without problems, but new data is no added in the table. Does anybody know what the problem is?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
daidai
  • 531
  • 5
  • 10
  • 22

2 Answers2

2

You would need to call

de.SaveChanges(); 

if this is Entity Framework to persist the changes back to the database.

mservidio
  • 12,817
  • 9
  • 58
  • 84
0

You need to call the save method on de after you've added the object.

BenM
  • 4,218
  • 2
  • 31
  • 58