public static Program GetProgramV2(String programcode) { using (var context = new StudentManagerContext()) { //context.programs ins causing an error, LazyInternalConnection, connection.has model(). There is no model created so that's more that likly why. foreach (Program p in context.Programs) { if (p.ProgramCode == programcode) { return(p); } } return(null); } }
public static bool AddProgramV2(Program program) { using (var context = new StudentManagerContext()) { if (program != null) { context.Programs.Add(program); context.SaveChanges(); return(true); } else { return(false); } } }