‫Now that we've got our migration, we can go ahead and create our database based on the code in this
‫migration class.
‫Once again, we'll use the net F command line tool to do this.
‫So I'll just clear this window and then we can say net F and database.
‫And if we look at the help available for this command then we've got the option to drop the database
‫which is effectively going to delete it.
‫And we've got the option to update the database to a specified migration.
‫Or it's just going to apply all of the migrations that we have to update and create the database.
‫So let's go ahead and use that command.
‫And please do make sure your application is not running at this point, as I'm pretty sure this will
‫not work if your API server is running.
‫And we can say.
‫Net F database updates and press return.
‫And this is going to go ahead and build our application and create the database.
‫And once that has happened, then we'll see some outputs in our log files.
‫And if you're not seeing quite so much information, then the reason that I am seeing this level of
‫detail is inside the app settings development dot JSON.
‫Then I've got the Microsoft ASP.Net core set to information, and that means that I get info logs and
‫not just warning for these type of activities.
‫Inside here we can see that we're creating a table called F migrations history.
‫This keeps track of the migrations that have already been applied to the database.
‫And we are then creating the users table, and we're inserting a new entry into the F migrations history
‫table.
‫So let's go and take a look at our database.
‫So I'll just close these down.
‫And inside our solution explorer we now have a file called dating dot db.
‫And if I click on this then I can't open my database using VS code in this way because it's either binary
‫or uses an unsupported text encoding.
‫It's a database.
‫Don't forget it's not just a file where you can take a look at the text.
‫It is a file, but it's a SQLite file.
‫And we need to use a SQL Lite tool to be able to see what's inside that database.
‫Now, earlier on, one of our extensions that we installed is this SQL Lite extension.
‫Please make sure you have this installed as an extension if you want to follow what I'm doing exactly
‫here.
‫There are other database viewing tools available, but this one I could just use inside VS code.
‫If this one doesn't work for you, you don't like it.
‫You want something better.
‫Then the one that I would use as an alternative is called Dbeaver, which is a free universal database
‫tool.
‫It is outside of VS code, but it will allow you to view and do things with your database as well.
‫But I'm going to demonstrate the one that we can use inside VS code.
‫So in order to use the SQL Lite tool then we need to use our command palette once again.
‫So once again use the show all commands.
‫And I'm going to say shift command and P.
‫And then I'm going to look for SQL Lite and Open Database.
‫This is going to take a look in your solution and look for anything called DB.
‫That's the SQL Lite file.
‫And then we can open the database.
‫What this does is it gives us a new thing inside the explorer.
‫And we now have a SQL Lite Explorer.
‫And if we expand dating dot db we can see we've got a users table that has two columns an ID and a username.
‫And we also have our if migrations history with the migration ID and the product version.
‫And if we take a look at the entries inside this table, we can see what's been applied to our database.
‫And of course we don't have any users yet.
‫So if we hit play on this one we don't see anything inside there.
‫Now, just so that we've got some data to work with, let's just click on users, right click and then
‫say new Query and Insert.
‫And then this gives us the boilerplate code we need to use with SQL Lite to insert something into this
‫table.
‫Now it takes two arguments the id and the username.
‫And we're just going to specify this inside the values.
‫And I'm just going to manually enter some data inside here.
‫So I'm going to have an integer of one.
‫And I'm going to say Bob as the first one.
‫And then I'm just going to copy this down two more times.
‫And I'm going to create two more example users.
‫Don't worry, we won't be doing this at any other point in this training course, but I just want a
‫tiny bit of data to work with so that we can test an API controller endpoint which is forming part of
‫our walking skeleton.
‫So for the time being, we'll just manually create three records in our database.
‫Please ensure the integers are all different.
‫Otherwise Entity Framework will not accept this into our database.
‫And then once you have this in place, just highlight everything.
‫And then just right click and say run selected query.
‫And then this is going to go and create those three users in our database.
‫So you'll see something like that when it has been successful.
‫And then we can close this file down because we don't need to save it or do anything with it.
‫But then if I hit play on the users again now we can see that we've got three example users in our database,
‫and we can use these for early testing just to make sure that we can query our database and return data
‫from an API endpoint.
‫And to do that, we'll need an API controller, which will take a look at creating next.