-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
Steps to reproduce
- Make a new solution, add NumericId to the ApplicationUser class and make it look like this:
public class ApplicationUser : IdentityUser
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int NumericId { get; set; }
}
- Execute UserManager.UpdateAsync(user);
- Witness the error
The issue
For some reason EF is attempting to insert value into an Identity column which isn't allowed and throws an exception. Rest of the columns do NOT get updated.
However,
this bug also accured when I tried to register, but in that case, database wise, everything was Inserted, new user was registered and a proper NumericId was assigned to the user even though the front-end threw the exception. Few builds after, even though nothing has changed, registering stopped throwing the exception and functions properly.
Exception message:
SqlException: Cannot update identity column 'NumericId'.
MoveNext
DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
MoveNext
Stack trace:
System.Data.SqlClient.SqlException: Cannot update identity column 'NumericId'.
at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__107_0(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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__20.MoveNext()
--- 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.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext()
ClientConnectionId:5be684a0-2aee-4a9f-ac8b-9d4bcea49b47
Error Number:8102,State:1,Class:16
Further technical details
EF Core version: 1.0.0
Operating system: Windows 7 Professional
Visual Studio version: VS 2015 Enterprise edition
Other details about my project setup:
None.