In this section, you update the connection strings and run the migrations for the example projects.
- [Instructor] For this course, all of the code is already built, and available in the download code. There are three solutions broken down by version. And for each of the solutions, we need to update the connection strings. In both the application DB ContextFactory, and the app settings dot JSON file. Once the connection strings are confirmed and or updated, then you will execute to migrations for each project. And use our entity framework migrations.
And they create the database. Let's start with the one zero project, And let's go into the application DB ContextFactory. Now this is the file in connection that gets used by the migrations, not by the NVC app. And what we want to do is we want to make sure that the server is correct. Local DB is a special version of SQL express that's installed along with Visual Studio. So if you're going to continue using Local DB, you won't have to change this at all.
Each version has its own database. This is SpyStore underscore version one point zero. There's a one point one and a two zero. I'm running as a currently logged in user. And this is valid for the one point zero, and one point one versions. We'll talk about the differences in the two point zero. The next file to open is... The app settings dot JSON file. And let me expand solution explorer.
So app settings dot JSON file is in the NVC project. And the DB ContextFactory file is in the DAL project. For the one point zero and one point one, we just need to make sure that these connection strings match. They're going to be a little different in two point zero. And again we'll cover that shortly. Once we have the connection strings correct, we're going to run the migrations to create the database.
So I'm going to use the quick launch to find the package manager console. I already have it open. So it's in my MRU slot. And once I have that open, I can copy this final migration command. Put it in package manager console and execute it. Now if I just execute it right off the bat, I will get an error. Because we need to first change to the DAL directory where it can find the command line interface package.
And we'll talk about how that works when we get into the actual code. So as changed to the DAL directory, rerun the dot net EF database update command, and those are cumulative so it'll update all of the existing migrations. And you'll get a message saying that it's done. So the one point one is exactly the same. And just to confirm we go into the application DB ContextFactory. We check the server.
The database is V one one. And I'm using a trusted connection. App settings. Same. Migrations. Same. Go into package manager console, do the same thing. Change the DAL directory and then execute the migration. So this database didn't exist in my machine. It's now created. Let's go to the two point zero project where we have a little bit of a different setup. So if we go into the application DB ContextFactory, I am using SQL server express, and my named instance is SQL express 2016.
In the DB ContextFactory, I'm using trusted connection, but when we go into the app settings, we have to change it. And we'll talk more about the IP address for this when we get into the two point zero module, but we have to have the IP address as docker sees our machine. And then SQL express 2016... Comma. And this is the port that we saw when we went into the SQL server configuration manager.
The other difference that we need to do since this is going to be a remote connection, is we have to have supply a username and a password. So we confirmed that my database is installed. We'll do the same thing. On the DAL directory. Execute to migration. And my database was already up to date. Once you've done this, you'll be able to run all three projects.
- Running and debugging ASP.NET Core applications
- Pros and cons of migrating existing applications to ASP.NET Core.
- Built-in dependency injection
- Environment awareness and app configuration
- Web host configuration and SSL
- View components invoked as tag helpers
- Configuration and logging
- Using Razor Pages