예제 #1
0
 private static void DeleteDatabase2()
 {
     using (var context = new BooksContext2())
     {
         context.Database.EnsureDeleted();
     }
     Console.WriteLine("database deleted");
 }
예제 #2
0
 private static void CreateDatabase2()
 {
     using (var context = new BooksContext2())
     {
         context.Database.EnsureCreated();
         context.Books.Add(new Book("Professional C# 7 and .NET Core 2.0", "Wrox Press", "Christian Nagel"));
         context.SaveChanges();
     }
 }
예제 #3
0
 private static void CreateDatabase2()
 {
     using (var context = new BooksContext2())
     {
         context.Database.EnsureCreated();
         context.Books.Add(new Book("Professional C# 6", "Wrox Press"));
         context.SaveChanges();
     }
 }
예제 #4
0
 private static void ReadData2()
 {
     using (var context = new BooksContext2())
     {
         foreach (var book in context.Books)
         {
             Console.WriteLine(book);
         }
     }
 }