public void DeleteNinja(int ninjaId) { using (NinjaContext context = new NinjaContext()) { NijaDomain.Classes.Ninja ninja = context.Ninjas.Find(ninjaId); context.Entry(ninja).State = EntityState.Deleted; context.SaveChanges(); } }
public void SaveNewEquipment(NinjaEquipment equipment, int ninjaId) { //paying the price of not having a foreign key here. //reason #857 why I prefer foreign keys! using (NinjaContext context = new NinjaContext()) { NijaDomain.Classes.Ninja ninja = context.Ninjas.Find(ninjaId); ninja.EquipmentOwned.Add(equipment); context.SaveChanges(); } }