Scott
Scott

Reputation: 1167

Thinktecture IdentityServer 3 - ASP.NET Identity sample not working

I'm running the IdentityServer AspNetIdentity sample from https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNetIdentity. By itself, with the database in app.config set to (LocalDb), it works.

I've also done File/New Project on an MVC 5 + Web API 2 project. I've created a SQL database in Azure SQL, pointed the new project to that database, and created a new user in there, which means that ASP.NET Identity has run the database creation scripts, and I have the usual tables in there.

So, separately, they're fine.

I then went into the AspNetIdentity sample, and pointed it at the newly-created SQL database that was just populated. When I run the sample... it blows up. Specifically, in AspNetIdentityUserService.cs, on line 188, where it calls into UserManager.

    protected async virtual Task<TUser> FindUserAsync(string username)
    {
        return await userManager.FindByNameAsync(username);
    }

Exception:

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.

Am I misunderstanding something? Shouldn't the AspNetIdentity plugin be able to pull from a normally-formatted ASP.NET Identity database?

Upvotes: 1

Views: 1731

Answers (1)

Scott Brady
Scott Brady

Reputation: 5598

That sample is using an extended version of the base ASP.NET Identity IdentityUser. See the User entity.

This has the added properties of FirstName and LastName, which according to your exception, your database does not have.

Upvotes: 1

Related Questions