I have looked around and found ways of clearing a table using TRUNCATE, this however only works with tables that are not being referenced as a foreign key.
I have also found a method which describes finding the range of all the data, and then deleting that range. This is however a somewhat less efficient way, and would like to avoid it if there is a better alternative.
What would be the most efficient way to empty these 2 tables?
public class Product
{
public int ProductID { get; set; }
public String ProductNaam { get; set; }
[ForeignKey("Afdeling")]
public int? AfdelingID { get; set; }
public virtual Afdeling Afdeling { get; set; }
}
public class Afdeling
{
public int AfdelingId { get; set; }
public string Naam { get; set; }
}
I am using Visual Studio 2013 Ultimate in a .net 4.5 WPF project, with Entity Framework 6.1.2 and LocalDB