public static void PrintUser() { using (var db = new CreateProjectContext()) { var query = from b in db.Users orderby b.UserName select b; foreach (var item in query) { Console.WriteLine(item.UserName); } } }
public static bool AddUser() { try { using (var db = new CreateProjectContext()) { var user = new User(); user.UserID = "1"; user.UserName = "******"; db.Users.Add(user); db.SaveChanges(); return(true); } } catch (Exception ex) { } return(false); }