Join Phil Japikse for an in-depth discussion in this video Installing the prerequisites, part of Entity Framework Core Essential Training: 1.
- [Narrator] Alright, let's get into installing the required software for this course. We're going to start with Visual Studio 2017 Community. And if you haven't installed 2017 yet the installation experience is radically different but in my opinion much-improved. The installation process is now divided into workloads. So you'll want to select the .NET desktop development and .NET Core cross-platform development and that's going to handle our Windows and our other tool sets, and we'll see that shortly.
There's some individual components that you're going to want to select. The .NET Framework 4.7.1 SDK and targeting pack that way we can use all the 7.1 features in our application. And then optionally you're going to want to install the Git for Windows and GitHub Extension for Visual Studio. As a reminder when you install Visual Studio it will install LocalDB for you and you can download it at the link on your screen but it's easy to remember, VisualStudio.com.
Let's look at the installer. Another nice feature in 2017, if you weren't aware of it, you can have true side by side installation of Visual Studio. Now this is the same version as in 2017 can be installed more than once, so here on my machine I've got an installer named courses and this is Community right here. And then I have, for my work and for my customers, Visual Studio Enterprise, but I do all my courses and my books using Community.
So if you have a work-supplied copy of Visual Studio and you don't feel comfortable doing personal work with a corporate-supplied copy of Visual Studio and your rules and restrictions are certainly probably unique to your situation so you know better than I do but you can always install Community on the same machine without having to fire up a VM like we had to in the past. Let's go into modify and look at the workloads. Now I have more installed on my machine than you need for this course but here is the .NET desktop development.
So this gives us the console applications, you know all the WPF and Windows Forms. We're not going to be using WPF or Windows Forms but we will be working with console applications and class libraries. I have ASP.NET and web development on here. This gives ASP.NET Core, and you don't need it for this course, but you probably need it for other courses you might be doing. And we go all the way to the bottom and then we have here our .NET Core cross-platform development workload.
And so we're going to want to check that as well. When you go into individual components what I like to select is the 4.7.1. And just make sure that I'm current with all the versions on here and then up here at the top the .NET Core runtime. We're going to mainly install the SDK but it's just good to check that. So then you would do a modify or install depending on if this was first or not.
The one thing to point out is if you have more than one version of Visual Studio 2017 you're going to have to add a nickname to your subsequent installations. So here I've called my Community Edition installation Courses to keep it separate from my work. Moving on we want to install .NET Core SDK and I recommend installing both the 32 and 64 bit versions of the SDK.
And you can get that from the link on your screen and once you have those installed we're going to want to confirm that they are installed and we can do this very simply in a command prompt by typing in... First of all, we would do where dotnet. And that shows us where we have the dotnet executable and I've got both the 64 and 32 bit versions on here. And then if we just do the command dotnet it's going to prompt us to say, hey, you need to say version, you can also do info, which it doesn't show here on the screens.
Let's do dotnet dash dash version. And we see that I'm running 2.1.3 and that is the CLI or command line interface version. But let's get a little bit more info. Let's do dotnet dash dash info. What we get here is we see the command line tools are 2.13 as we just saw. But the actual .NET Core framework is 2.0.4.
The command line tooling, that is how we run our commands such as .NET run, .NET EF, migrations, the .NET EF command line tools, so that's running 2.13 but the actual framework that we're running our .NET Core application under is 2.0.4. So those are different versions of that. So the next thing you want to install is SQL Server Management Studio.
And again it's not dependent on the version of SQL Server installed anymore, it's a nice thing, so we can have SQL Server Management Studio Version 17 loaded. And you can install it from the link that is on your screen which is the docs.microsoft.com link or when you're installing SQL Server, any edition, Express or Developer, et cetera, there is a link to install SSMS from that installer.
But it just takes you to the link that I'm showing you on this screen. So the link is the best way, I'm not going to go through the options it's a pretty straight forward install. Okay next let's restore AdventureWorks 2016. You can either get it from the download files as we discussed, or, we can download it from the link on your screen. So if you haven't done a restore before then I will walk you through it, if you have, then you'll just want to make sure you overwrite existing database with replace.
Want to change the owner to sa and then we are going to have to update a foreign key. So let's go ahead and get this done. So I already have it here, but if you didn't, you would simply right-click on databases and say restore database. You'll want to change it to device. Select your file. And in this case I have it in my GitHub folder.
Lynda, EFCore, Essentials, Course One. And this is what it is called in your download file, AW2016.bak, so we would accept that, say OK. You can leave the files tab the same and in the options you're going to want to check overwrite the existing database with replace.
And then click OK. I'm not going to do it, I already have it installed. So once you get it restored, we want to then change the owner to sa. Now this might not have to be done. If you right click, go to properties, you see on general, the owner is sa, if you don't have a valid owner you won't be able to make database diagrams. So, we can simply go, New Query.
Make sure the AdventureWorks 2016 is selected. And then we would just say exec sp underscore change db owner sa, and, we run that, and it changes the database owner for AdventureWorks 2016 to sa. Now that you have changed the owner to sa you can create or use database diagrams.
So we're going to expand the database diagrams node. If this is your first time into this database you'll be prompted with a message that says, would you like to install the support files for database diagrams? And just answer yes. I have one out here called product. But we're going to create a new one in case you're not using my copy so let's click on new database diagram. There was a little bit of a quirk when I was running through this before recording I got an error message that said index is outside the bounds of the array and it wouldn't pull up the table.
The simple solution, as with a lot of Microsoft products, is, close down SQL Server Management Studio and re-open it. So we want to add in the product table right here. And say add. And then we're going to do a little trick. You right click and say add related tables and it'll add a whole bunch of tables for us. And when it is done, we click somewhere else.
Right click and then say arrange tables. And that pretties up the diagram for us. Now a change that we have to make is a very simple one. We are looking for the foreign key product unit measure wait unit measure code foreign key, and that's this one, so we just say properties. And what we have to change, now I've already changed it on mine, so this would have shown up as no action, that this is a brand new restore of AdventureWorks.
So we want to make sure we change it to set null on the delete rule. This fixes a glitch with scaffolding the database. It's not a glitch, because it's not a problem with EF, it is just a poorly-defined relationship. So we come out, you'll see a little asterisk by your diagram that means that it needs to be saved. When you click on save, it'll prompt you for a name, we'll just leave it as diagram zero. For here, it tells you that you are changing some tables and then just say yes.
I'm going to say no 'cause I don't this. I've already made those changes. The final install is optional, it's SQL Server Express. If you're using AdventureWorks 2017 and you want to use SQL Server 2017 then it's not optional. You will have to install SQL Server Express 2017 to work with the AdventureWorks 2017 backup. If you want to stick with 2016 then LocalDB is all that you actually need.
As a general rule when I install SQL Server Express I always select SQL Server and Windows Authentication. Not required for this course, it's just something that I am in the habit of doing, and you can download SQL Server from the link on your screen. And that completes installing all the prerequisites for this course.
- Entity Framework Core components and projects
- Working with scaffolded files
- Testing with xUnit
- Viewing generated SQL
- Composing queries
- Sorting and filtering results
- Working with aggregates
- Loading related data
- Logging and tracking
- Mapping functions
- Generics and delegates
- Checking concurrency
- Resiliency and transactions