Entity Framework SaveChanges does not save data

99封情书 提交于 2019-12-01 06:30:18

问题


using (var db = new dbEntities())
{
    var dbUser = (from u in db.Users
                  where u.Id == Id
                  select u).First();

    dbUser.LastName = LastName;
    dbUser.FirstName = FirstName;
    dbUser.GroupId  = GroupId;
    dbUser.VoicesCount = VoicesCount;

    db.SaveChanges();
 }

This does not save any changes to the database. But there are no exceptions, either. Why?

UPD: Ok, I tried it also for SQL Server CE and nothing changes. It doesn't save the changed data.


回答1:


Look in you bin/debug folder for a copy of the database, it will have the changed data, as you are including the database a content with your app



来源:https://stackoverflow.com/questions/10772713/entity-framework-savechanges-does-not-save-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!