MVC Controllers (Cont.)


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": {
       "BookStore1Context":
       "Server=localhost\\XQLEXPRESS03;
         Database=BookStore1Context;
         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. Go to the located at


Enter the following command:

Add-Migration BookStore1.Data.BookStore1Context

This will create the classes for supporting migrations, which provide a way to incrementally update the database schema to keep it in sync with the application’s data model while preserving existing data.



 





      “‘What’s a couple?’ I asked my mum.    
      She said, ‘Two or three’.    
      Which probably explains why her marriage collapsed.”    
      — Josie Long