且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架未将更改保存到数据库中

更新时间:2023-02-12 10:39:12

使用

saccldb.SaveChanges()

仅因为await saccldb.SaveChangesAsync()的异步特性导致线程继续执行并退出函数,然后完成保存到数据库的操作.就您而言,它返回true.

Simply because the async nature of await saccldb.SaveChangesAsync() cause your thread to continue and exit the function before the saving to the db completes. In your case it returns true.

我建议不要在控制台应用程序上使用任何异步操作,除非它具有您希望继续使用的用户界面.

I would suggest not using any async operations on a console application unless it has a user interface that you would want to keep going.