I want to create a cascading dropd own list. For that I created 3 model classes State,District and User. But while running an exception occured.
public class State
{
public int StateID { get; set; }
public string StateName { get; set; }
}
public class District
{
public int DistrictID { get; set; }
public string DistrictName { get; set; }
public int StateID { get; set; }
public virtual State state { get; set; }
}
public class User
{
public int UserID { get; set; }
public string UserName { get; set; }
public int StateID { get; set; }
public int DistrictID { get; set; }
public virtual State state { get; set; }
public virtual District district { get; set; }
}
The exception is,
"An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Introducing FOREIGN KEY constraint 'FK_dbo.Users_dbo.States_StateID' on table 'Users' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint. See previous errors."
Can anyone help me to solve this problem?