I am doing CRUD operation using asp .net core 6 MVC (visual studio 2022). For this i complete County Create,Update,Delete,Read operation. but now i am trying cascading dropdown in state with relation county db. when i write "public virtual CountryMaster CountryMaster" and "public virtual ICollection StateMasters" in the models on state and country it give me error of sqlException:Invalid column name 'CountryMasterCountryId'. here is CountryMaster model '''
{
[Key]
public int CountryId { get; set; }
[Display(Name = "Country Name")]
[Required(ErrorMessage ="Please Enter Country")]
public string CountryName { get; set; } = null!;
[Display(Name ="When Entered")]
public DateTime WhenEntered { get; set; } = DateTime.UtcNow;
[Display(Name ="When Modified")]
public DateTime WhenModified { get; set; }= DateTime.UtcNow;
public virtual ICollection<StateMaster> StateMasters { get; set; }
} '''
here is StateMasters model '''
{
[Key]
public int StateId { get; set; }
[Required(ErrorMessage ="Please Enter State Name")]
public string StateName { get; set; } = null!;
[Display(Name = "Country Name")]
public int CountryId { get; set; }
[Display(Name = "When Entered")]
public DateTime WhenEntered { get; set; } = DateTime.UtcNow;
[Display(Name = "When Modified")]
public DateTime WhenModified { get; set; } = DateTime.UtcNow;
public virtual CountryMaster CountryMaster { get; set; }
}
''' What i do? Is Icollection different in .net core 6 MVC?