When you work with the Entity Framework
from an ASP.NET Core project, at least one
created from one of Microsoft templates,
there's nothing additional that you have
to do to work with the Entity Framework in
this project. And that's because if I look
at the NuGet dependencies that are
associated with this project, I see the
package Microsoft.AspNetCore .App, which
is what we call a metapackage. This
package exists to bring in other packages,
and if I do a search for Entity Frramework
or just entityf, I can see that this
AspNetCore.App metapackage brings in
additional NuGet packages that bring in
all the Entity Framework functionality
that we might need. However, we're using a
slightly different setup. Yes, ultimately
we want to use the Entity Framework from
the OdeToFood project, but we've also
separated out our data access into
OdeToFood.Data, and this particular
project does not reference any NuGet
packages currently. This is just a simple,
humble class library. When I build out the
classes that are going to use the Entity
Framework, I want to put those classes
into OdeToFood.Data, and that means
ultimately this project is going to need a
reference to those Entity Framework NuGet
packages. So I'm going to right-click on
the project, say that I want to Manage
NuGet Packages. This is something you can
do from the command line using the dotnet
add command. What I want to do is go out
and browse and search for Entity Framework
Core. So I want to make sure I'm using the
Entity Framework Core, not just the Entity
Framework. I'm going to install the latest
stable version, which for me is 2.1 .4. To
do that, I need to accept the license
agreement. And then as soon as that is
finished, there's actually some additional
packages that I want to install. This
version of the Entity Framework, Entity
Framework Core, supports a variety of
different databases, and the package that
I just installed is the core of the Entity
Framework Core, if you will. When I go to
work with a specific type of database,
like Microsoft SQL Server, then there are
these additional NuGet packages that will
add in support for a specific database
provider like SQL Server. So I'm also
going to install,
Microsoft.EntityFrameworkCore .SqlServer.
Once this has finished installing, there
is one additional package that I want to
install, and that is a package named
Design. That package is squeezed into the
second location here in the list, and it
is Microsoft.EntityFrameworkCore .Design.
Let me also install this package. While
that's installing, let me right-click and
open up OdeToFood.Data .csproj so you can
see what this looks like. What I have done
is installed these three packages, which
you could also do by modifying the CSPROJ
file directly, but I am now ready to work
with the Entity Framework from my OdeToFood.Data project.