【发布时间】:2015-11-14 14:25:39
【问题描述】:
我正在运行来自https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNetIdentity 的 IdentityServer AspNetIdentity 示例。就其本身而言,将 app.config 中的数据库设置为 (LocalDb),它就可以工作。
我还在 MVC 5 + Web API 2 项目上完成了文件/新建项目。我在 Azure SQL 中创建了一个 SQL 数据库,将新项目指向该数据库,并在其中创建了一个新用户,这意味着 ASP.NET Identity 已经运行了数据库创建脚本,并且我在其中有常用的表。
所以,分开来说,他们很好。
然后我进入 AspNetIdentity 示例,并将其指向刚刚填充的新创建的 SQL 数据库。当我运行样本时......它爆炸了。具体来说,在 AspNetIdentityUserService.cs 的第 188 行,它调用了 UserManager。
protected async virtual Task<TUser> FindUserAsync(string username)
{
return await userManager.FindByNameAsync(username);
}
例外:
SelfHost.vshost.exe Error: 0 : [Thinktecture.IdentityServer.Core.Configuration.Hosting.ErrorPageFilterAttribute]: 8/20/2015 7:26:40 PM +00:00 -- Exception accessing: /core/login
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid column name 'FirstName'. Invalid column name 'LastName'.
at System.Data.SqlClient.SqlCommand.<>c__DisplayClass16.<ExecuteDbDataReaderAsync>b__17(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext()
--- End of inner exception stack trace ---
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
etc.
我是不是误会了什么? AspNetIdentity 插件不应该能够从正常格式的 ASP.NET 身份数据库中提取吗?
【问题讨论】:
标签: asp.net-mvc asp.net-identity thinktecture-ident-server