C# ASP.NET标识返回元数据资源错误
我正在尝试创建一个ASP.NET标识系统,我已经完成了页面的一半,但是当我开始编写以下代码时C# ASP.NET标识返回元数据资源错误,c#,asp.net-mvc,asp.net-identity,C#,Asp.net Mvc,Asp.net Identity,我正在尝试创建一个ASP.NET标识系统,我已经完成了页面的一半,但是当我开始编写以下代码时 public async Task<string> AddUser() { ApplicationUser user; ApplicationUserStore Store = new ApplicationUserStore(new ApplicationDbContext()); Ap
public async Task<string> AddUser()
{
ApplicationUser user;
ApplicationUserStore Store = new ApplicationUserStore(new ApplicationDbContext());
ApplicationUserManager userManager = new ApplicationUserManager(Store);
user = new ApplicationUser
{
UserName = "bla",
Email = "o@gmail.com",
};
var result = await userManager.CreateAsync(user);
if (!result.Succeeded)
{
return result.Errors.First();
}
return "User Added";
}
DbContext基于使用以下SQL创建的此连接字符串中的表
CREATE TABLE [dbo].[UsersTable](
[UserID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nchar](200) NOT NULL,
[Email] [nchar](200) NOT NULL,
[EmailConfirmed] [bit] NOT NULL,
[Password] [nchar](200) NOT NULL,
[Hospital] [nchar](200) NOT NULL,
[Salt] [nvarchar](500) NOT NULL,
CONSTRAINT [PK_UsersTable] PRIMARY KEY CLUSTERED
(
[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
你看过这个吗@DavidG我确实看过了,但它涉及到元数据的.edmx文件,我的项目没有很好地包含这些元数据,因为您没有向我们展示任何与您的上下文相关的内容,我们只能猜测。这里没有足够的信息来回答这个问题。为了让我的问题有上下文,你还需要什么?我对ASP.NET身份非常陌生,所以我知道的很少。那么,首先来看看
ApplicationDbContext
?你给了它什么配置?您的连接字符串是什么样子的?
CREATE TABLE [dbo].[UsersTable](
[UserID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nchar](200) NOT NULL,
[Email] [nchar](200) NOT NULL,
[EmailConfirmed] [bit] NOT NULL,
[Password] [nchar](200) NOT NULL,
[Hospital] [nchar](200) NOT NULL,
[Salt] [nvarchar](500) NOT NULL,
CONSTRAINT [PK_UsersTable] PRIMARY KEY CLUSTERED
(
[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO