I have Table like the following image:
how can I delete all records of table using Entity FrameWork based on ProjectId ?
This one liner will do it:
db.ProRel.RemoveRange(db.ProRel.Where(c => c.ProjectId == Project_id));
context.Projects.Where(p => p.ProjectId == projectId)
.ToList().ForEach(p => context.Projects.Remove(p));
context.SaveChanges();
Taken from this very similar post (which should probably be marked as duplicate).