public Subject CreateSubject(Subject subject) { using (var database = new Core.Entity.SeedsEntities()) { var entity = subject.ToEntity(database); database.AddToSubject(entity); database.SaveChanges(); var result = new Subject(database.Subject.Execute(MergeOption.NoTracking).Single(s => s.ID == entity.ID)); result.UpdateParent(); Cache.Instance.Subjects[result.ID] = result; return result; } }