Cannot insert the value NULL into column 'RoleId' (mvc4 simple membership)
问题 I noticed that someone else has faced the same problem such as Cannot insert the value NULL into column 'UserId' but it should be caused by different reasons. The problem can be simplified like this: UsersContext _usersContext = new UsersContext(); ... var usersInRole = new UsersInRole() { RoleId = 3, UserId = 1 }; _usersContext.UsersInRoles.Add(usersInRole); _usersContext.SaveChanges(); The last line of code threw an exception "An error occurred while updating the entries. See the inner