I am currently getting an error I understand the error but I don't know where I am going wrong
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_dbo.AspNetUsers_dbo.CompanyDetails_userCompanyID". The conflict occurred in database "PXWHITESPIDERDEV", table "dbo.CompanyDetails", column 'companyID'.
Within the IdentityModel autogenerated when you create an MVC application
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public int userCompanyID { get; set; }
[ForeignKey("userCompanyID")]
public CompanyDetails company { get; set; }
}
and here is the entity I am 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 within the RegisterViewModel class
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 companyID's were the same within the ApplicationUser class and the CompanyDetails class as in they had the same variable name. I thought this was the problem so changed the variable name within the ApplicationUser class, until I tried to update the database again and found out this was not the case.