UserManager.AddToRole not working - Foreign Key error
问题 In my ASP.NET MVC application I have some code which should be fairly trivial: UserManager.AddToRole(user.id, "Admin"); I just get this error... The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId". The conflict occurred in database "TestDatabase", table "dbo.AspNetRoles", column 'Id'. My ASP.NET Identity Framework is custom in that everything uses Guid as keys instead of int or string . Any ideas what is causing this? Edits, as per