Controllers (Cont.)


Go to the Package Manager Console located at


Enter the following command:

Add-Migration BookStore1.Data.BookStore1Context

This will create the classes for supporting migrations.



 


Now, we need to apply those changes to the database. Before that, make sure the connection string specified in the file points to the database server that we want to connect:
   {
    "Logging": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft.AspNetCore": "Warning"
      }
    },
    "AllowedHosts": "*",
    "ConnectionStrings": {
       "BookStoreWithDBContext":
       "Server=localhost\\XQLEXPRESS03;
         Database=BookStore1Context-0b35f143-69b8-490c-80cf-b122206efbdd;
         User ID=wenchen;
         Password=database;
         Encrypt=False;
         Trusted_Connection=True;
         MultipleActiveResultSets=true"
     }
   }
By default, the scaffolding process makes it point to the SQL Server Express local DB. For applying the changes to the database, let’s run the following command:

Update-Database


This will update the database based on our models:





      On birthdays during his childhood:    
      “When I was 10 there wasn’t trampolines and cartoon characters,    
      I never went to Chuck E. Cheese!    
      My mom said, ‘You wanna see a mouse,    
      pull the refrigerator out!’”    
      — George Lopez