I am currently receiving an error message I understand the error, but I do not know where I am mistaken
The ALTER TABLE statement was against the FOREIGN KEY constraint "FK_dbo.AspNetUsers_dbo.CompanyDetails_userCompanyID". The conflict occurred in the database "PXWHITESPIDERDEV", the table "dbo.CompanyDetails", in the column "company identifier".
Internally, IdentityModel is automatically generated when an MVC application is created.
public class ApplicationUser : IdentityUser { public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) {
and here is the object I'm trying to create
public class CompanyDetails { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int companyID { get; set; } [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 1)] [Display(Name = "Company Name")] public string CompanyName { get; set; } }
and inside the class RegisterViewModel
public class RegisterViewModel { [Required] [EmailAddress] [Display(Name = "Email")] public string Email { get; set; } [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm password")] [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] public string ConfirmPassword { get; set; } public CompanyDetails company { get; set; } }
before the company identifier was the same in the ApplicationUser class and in the CompanyDetails class, as was the case with the same variable name. I thought this was a problem, so the variable name in the ApplicationUser class changed until I tried to update the database and found out that it wasnβt.
source share