If created a website using MVC3 and have a database attached to it.
They are all linked together. I have a table for countries, table for states, table for cities. Now when I delete for example a country, the states and cities attached to it still remain in the database. I cant see them in the controllers list, but they do show up in the dropdown when choosing for example a state when creating a city. How do I fix this ?
thanks in advanced.
Use foreign key relationships set them to ON DELETE CASCADE as shown in the screenshot. That way when you delete a country, it will automatically delete the states, cities, etc that depend on it.
Or manually loop through and delete them yourself starting with cities, then their states and then the parent country.
You should be using foreign keys though..