private static void DbInit() { using (Applivationdb db = new Applivationdb()) { db.Database.EnsureDeleted(); db.Database.EnsureCreated(); } }
private static void Read(int Id) { using (Applivationdb db = new Applivationdb()) { Student stu = db.Students.Find(Id); Console.WriteLine(stu); } }
private static void Delete(int id) { using (Applivationdb db = new Applivationdb()) { Student stu = db.Students.Find(id); db.Students.Remove(stu); } }
private static void Upadte(int id, string newEmail, string newName) { using (Applivationdb db = new Applivationdb()) { Student stu = db.Students.Find(id); stu.Name = newName; stu.Email = newEmail; db.SaveChanges(); } }
public static void Create(string name, string email) { using (Applivationdb db = new Applivationdb()) { Student student = new Student() { Name = name, Email = email }; db.Students.Add(student); db.SaveChanges(); } }