Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Wrong property name #1052

Closed
fabiano opened this issue Dec 12, 2016 · 2 comments
Closed

Wrong property name #1052

fabiano opened this issue Dec 12, 2016 · 2 comments
Assignees

Comments

@fabiano
Copy link
Contributor

fabiano commented Dec 12, 2016

Hi,

I'm receiving the error below when I try to change a user's password using the Microsoft.AspNet.Identity.AspNetCoreCompat project.

An exception of type 'System.ArgumentException' occurred in EntityFramework.dll but was not handled in user code

Additional information: The property 'ConcurrencyToken' on type 'ApplicationUser' is not a primitive or complex property. The Property method can only be used with primitive or complex properties. Use the Reference or Collection method.

The cause is in the line https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNet.Identity.AspNetCoreCompat/IdentityDbContext.cs#L129.

There is no ConcurrencyToken property in the IdentityUser class. Changing the line to entityEntry.Property("ConcurrencyStamp").CurrentValue = Guid.NewGuid().ToString(); fixed the error.

And I had to convert the Guid to string since the type of the ConcurrencyStamp property is string.

How to replicate:

  • Create an ASP.NET MVC 4.6.1 application with Individual User Accounts
  • Reference the AspNet.Identity.CoreCompat assembly
  • Change the ApplicationUser class to inherit from the Microsoft.AspNet.Identity.CoreCompat.IdentityUser
  • Change the ApplicationDbContext class to inherit from the Microsoft.AspNet.Identity.CoreCompat.IdentityDbContext
  • Run the application
  • Create a user and try to change the password
@divega
Copy link

divega commented Dec 12, 2016

@HaoK OnModelCreating() refers to ConcurrencyStamp but ValidateEntity() refers to ConcurrencyToken as string so I guess it is just a typo. FWIW, you can use lambdas in ValidateEntity() 😄

@divega divega added the bug label Dec 12, 2016
@divega divega modified the milestones: 1.1.0, 1.2.0 Dec 12, 2016
@HaoK HaoK added the 3 - Done label Jan 4, 2017
@HaoK
Copy link
Member

HaoK commented Jan 4, 2017

d4d105d

@HaoK HaoK closed this as completed Jan 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants