ASP.NET MVC 5:UserManager.CreateAsync(user,model.Password);没有将用户添加到数据库 [英] ASP.NET MVC 5: UserManager.CreateAsync(user, model.Password); is not adding user to the database

查看:101
本文介绍了ASP.NET MVC 5:UserManager.CreateAsync(user,model.Password);没有将用户添加到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET身份模板创建用户.

I am creating users using the ASP.NET identity template.

用于创建用户的主要代码是

Main code for user creation is

await UserManager.CreateAsync(user, model.Password);

返回成功.

我能够通过新创建的用户登录,但是我无法在数据库表 aspnetusers 中看到这些用户.

I am able to login via the newly created user, but I am not able to see those users in database table aspnetusers.

我也尝试过注册用户视图google,创建了用户,也可以登录,但是他们不在数据库表中.

I have tried registering user view google also, user gets created, able to login also, but they are not there in database table.

表中最初创建的用户很少,但是刷新 .edmx 后,看不到它们.

I have few users in my table that I had created in the beginning, but after refreshing the .edmx, I am not seeing them.

任何帮助将不胜感激.

更新我在旧的上面的web.config中添加了一个默认的连接字符串,现在aspnet身份正将我的数据库用于所有目的.新的连接字符串是:

Update I added a default connection string in web.config above the old one, now aspnet identity is using my database for all the purposes. new connection string is :

<add name="DefaultConnection" connectionString="Data Source=DESKTOP-MVNRJK0\SQLS17;  Initial Catalog=OxfordLibrary;Integrated Security=True"
  providerName="System.Data.SqlClient" />

推荐答案

我猜所有用户都保存在名为默认连接"的连接字符串指定的LocalDb文件中.确保连接字符串以及连接字符串中的凭据正确无误.

I'm guessing that all the users are being saved in LocalDb file specified by your connection string named "Default Connection". Make sure the connection string is correct as well as the credentials inside the connection string.

在DBContext类中,也许在Identity模型中,请确保连接字符串不是"DefaultConnection".请让我知道是否还有其他问题.:)

In the DBContext class, maybe inside Identity models, make sure the connection string is not "DefaultConnection").Let me know if there's any further problems. :)

这篇关于ASP.NET MVC 5:UserManager.CreateAsync(user,model.Password);没有将用户添加到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆