简体   繁体   中英

Entity Framework object not persisting/saving to database table

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?

You would need to call

de.SaveChanges(); 

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

添加对象后,需要在de上调用save方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM