NuGet do I need to install Microsoft.EntityFrameworkCore if all I need is its provider?

.net-core c# entity-framework-core nuget nuget-package


I'm relatively new to NuGet. I plan to make only use of a sqlite database in my project. Using the NuGet Packet Manager I saw that there are several packages related to Microsoft.EntityFrameworkCore.

If make use of only sqlite would the Microsoft.EntityFrameworkCore.Sqlite package suffice or is it also important to install Microsoft.EntityFrameworkCore package?

I feel a bit confused, when should I install Microsoft.EntityFrameworkCore instead of Microsoft.EntityFrameworkCore.Sqlite and vice versa?

10/20/2019 12:42:35 AM

Accepted Answer

If you are referencing a package via PackageReference, you automatically get all of it's dependencies as well.

Microsoft.EntityFrameworkCore.Sqlite 3.0.0 (targeting .NETStandard 2.1) depends on Microsoft.EntityFrameworkCore.Sqlite.Core 3.0.0, which depends on Microsoft.EntityFrameworkCore.Relational 3.0.0, which eventually depends on Microsoft.EntityFrameworkCore 3.0.0 (which now further depends on other packages).

So a PackageReference of

    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0" />

gets your project not only the top-level package, but also all transitive dependencies as dependency graph - if the PackageReferences of those projects in return isn't tagged with PrivateAssets to prevent the flow to the parent project, as described in the docs.

You can review all the assemblies consumed by your project via the Solution Explorer of Visual Studio: VisualStudio-SolutionExplorer

Or alternatively via the .NET Core CLI by typing: dotnet list package --include-transitive

Project 'Project' has the following package references
   Top-level Package                           Requested   Resolved
   > Microsoft.EntityFrameworkCore.Sqlite      3.0.0       3.0.0

   Transitive Package                                           Resolved
   > Microsoft.Data.Sqlite.Core                                 3.0.0
   > Microsoft.DotNet.PlatformAbstractions                      3.0.0
   > Microsoft.EntityFrameworkCore                              3.0.0
   > Microsoft.EntityFrameworkCore.Abstractions                 3.0.0
   > Microsoft.EntityFrameworkCore.Analyzers                    3.0.0
   > Microsoft.EntityFrameworkCore.Relational                   3.0.0
   > Microsoft.EntityFrameworkCore.Sqlite.Core                  3.0.0
   > Microsoft.Extensions.Caching.Abstractions                  3.0.0
   > Microsoft.Extensions.Caching.Memory                        3.0.0
   > Microsoft.Extensions.Configuration                         3.0.0
   > Microsoft.Extensions.Configuration.Abstractions            3.0.0
   > Microsoft.Extensions.Configuration.Binder                  3.0.0
   > Microsoft.Extensions.DependencyInjection                   3.0.0
   > Microsoft.Extensions.DependencyInjection.Abstractions      3.0.0
   > Microsoft.Extensions.DependencyModel                       3.0.0
   > Microsoft.Extensions.Logging                               3.0.0
   > Microsoft.Extensions.Logging.Abstractions                  3.0.0
   > Microsoft.Extensions.Options                               3.0.0
   > Microsoft.Extensions.Primitives                            3.0.0
   > SQLitePCLRaw.bundle_e_sqlite3                              2.0.0
   > SQLitePCLRaw.core                                          2.0.0
   > SQLitePCLRaw.lib.e_sqlite3                                 2.0.0
   > SQLitePCLRaw.provider.dynamic_cdecl                        2.0.0
   > System.Collections.Immutable                               1.6.0
   > System.ComponentModel.Annotations                          4.6.0
   > System.Diagnostics.DiagnosticSource                        4.6.0
   > System.Memory                                              4.5.3
   > System.Text.Json                                           4.6.0
   > System.Threading.Tasks.Extensions                          4.5.2

To answer your second question: You may want to just install Microsoft.EntityFrameworkCore for database provider agnostic class libraries, providing general Entity Framework Core functionality.

10/23/2019 8:49:58 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow