Thinktecture IdentityServer 3 - ASP.NET 身份样本不工作
Thinktecture IdentityServer 3 - ASP.NET Identity sample not working
我正在 运行 使用来自 https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNetIdentity 的 IdentityServer AspNetIdentity 示例。就其本身而言,app.config 中的数据库设置为 (LocalDb),它可以正常工作。
我还在 MVC 5 + Web API 2 项目上完成了 File/New 项目。我在 Azure SQL 中创建了一个 SQL 数据库,将新项目指向该数据库,并在其中创建了一个新用户,这意味着 ASP.NET 身份具有 运行数据库创建脚本,我在那里有常用的表。
所以,单独来看,它们都很好。
然后我进入 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 身份 IdentityUser
的扩展版本。参见User
entity。
这具有 FirstName
和 LastName
的附加属性,根据您的例外情况,您的数据库没有。
我正在 运行 使用来自 https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNetIdentity 的 IdentityServer AspNetIdentity 示例。就其本身而言,app.config 中的数据库设置为 (LocalDb),它可以正常工作。
我还在 MVC 5 + Web API 2 项目上完成了 File/New 项目。我在 Azure SQL 中创建了一个 SQL 数据库,将新项目指向该数据库,并在其中创建了一个新用户,这意味着 ASP.NET 身份具有 运行数据库创建脚本,我在那里有常用的表。
所以,单独来看,它们都很好。
然后我进入 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 身份 IdentityUser
的扩展版本。参见User
entity。
这具有 FirstName
和 LastName
的附加属性,根据您的例外情况,您的数据库没有。