I have a table that contains a bunch of duplicates. These are exact duplicates, minus the primary key column, which is an integer identity column.
Using EF and LINQ,
Building on @Craig Stuntz's answer with a "one liner" alternative:
var duplicates = db.Table.GroupBy(a => new { a.FieldA, a.FieldB, ...}) .Where(a => a.Count() > 1) .SelectMany(a => a.ToList()); foreach (var d in duplicates) { db.DeleteObject(d); } db.SaveChanges();