Exemplo n.º 1
0
 private static void DeleteDatabase2()
 {
     using (var context = new BooksContext2())
     {
         context.Database.EnsureDeleted();
     }
     Console.WriteLine("database deleted");
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 4
0
 private static void ReadData2()
 {
     using (var context = new BooksContext2())
     {
         foreach (var book in context.Books)
         {
             Console.WriteLine(book);
         }
     }
 }