简体   繁体   English

如何在AspNetUsers表中保存字段

[英]How to save a field in the AspNetUsers table

I have added a new field to the AspNetUsers table for the MVC application using EntityFramework code first model. 我已经使用EntityFramework代码优先模型为MVC应用程序的AspNetUsers表添加了一个新字段。 I can access the field in one of my controllers by doing: 我可以通过执行以下操作之一来访问我的控制器中的字段:

 var currentUser = await HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindByIdAsync(User.Identity.GetUserId());
 bool isPrivateModeOn = currentUser.IsPrivateMode;

How do I actually set a value (true/false) back to the field in the database? 我实际上该如何将值(true / false)设置回数据库中的字段? can someone please help? 有人可以帮忙吗? Thanks. 谢谢。

您可以使用UpdateAsync方法来更新用户属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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