Beth
Beth

Reputation: 1685

Determine version of Entity Framework I am using?

I believe there are two versions 1 and 2? And version 2 is referred to as Entity Framework 4.0?

How can I tell what version is being used in an application?

This is in my web.config does this mean I am using version 2?

<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Upvotes: 165

Views: 164971

Answers (12)

Mark Worrall
Mark Worrall

Reputation: 331

or in Visual Studio simply go to:

Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...

and it will show you the versions used for each project

Upvotes: 0

public static string GetEntityFrameworkDllVersion()
    {
        var efAssembly = System
            .AppDomain
            .CurrentDomain
            .GetAssemblies()
            .FirstOrDefault(x => x.FullName.Contains("EntityFramework"));

        if (efAssembly == null)
        {
            return "EF is not installed in project";
        }

        return efAssembly
            .GetCustomAttributes<AssemblyInformationalVersionAttribute>()
            .First()
            .InformationalVersion;
    }

Upvotes: 2

ChrisS
ChrisS

Reputation: 1959

Another way to get the EF version you are using is to open the Package Manager Console (PMC) in Visual Studio and type Get-Package at the prompt. The first line with be for EntityFramework and list the version the project has installed.

PM> Get-Package

Id                             Version              Description/Release Notes                                                                                                                                                                                          
--                             -------              -------------------------                                                                                                                                                                                          
EntityFramework                5.0.0                Entity Framework is Microsoft's recommended data access technology for new applications.                                                                                                                           
jQuery                         1.7.1.1              jQuery is a new kind of JavaScript Library....                                           

It displays much more and you may have to scroll back up to find the EF line, but this is the easiest way I know of to find out.

Upvotes: 193

Emmy Steven
Emmy Steven

Reputation: 143

For .NET Core, this is how I'll know the version of EntityFramework that I'm using. Let's assume that the name of my project is DemoApi, I have the following at my disposal:

  1. I'll open the DemoApi.csproj file and take a look at the package reference, and there I'll get to see the version of EntityFramework that I'm using.
  2. Open up Command Prompt, Powershell or Terminal as the case maybe, change the directory to DemoApi and then enter this command: 👉🏻 dotnet list DemoApi.csproj package

Upvotes: 1

Namig Hajiyev
Namig Hajiyev

Reputation: 1531

if you are using EF core this command below could help

dotnet ef --version

Upvotes: 31

Anzar Narmawala
Anzar Narmawala

Reputation: 21

In Solution Explorer Under Project Click on Dependencies->NuGet->Microsoft.NetCore.All-> Here list of all Microsoft .NetCore pakcages will appear. Search for Microsoft.EntityFrameworkCore(2.0.3) in bracket version can be seen Like this

After finding package

Upvotes: 2

Simple Fellow
Simple Fellow

Reputation: 4622

   internal static string GetEntityFrameworkVersion()
    {
        var version = "";
        var assemblies = System.AppDomain.CurrentDomain.GetAssemblies().Select(x => x.FullName).ToList();
        foreach(var asm in assemblies)
        {
            var fragments = asm.Split(new char[] { ',', '{', '}' }, StringSplitOptions.RemoveEmptyEntries).Select(x=> x.Trim()).ToList();
            if(string.Compare(fragments[0], EntityFramework, true)==0)
            {
                var subfragments = fragments[1].Split(new char[] { '='}, StringSplitOptions.RemoveEmptyEntries);
                version =subfragments[1];
                break;
            }
        }
        return version;
    }

Upvotes: 3

Demodave
Demodave

Reputation: 6632

If you go to references, click on the Entity Framework, view properties It will tell you the version number.

Upvotes: 4

Manoj Weerasooriya
Manoj Weerasooriya

Reputation: 639

can check it in packages.config file.

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.0.2" targetFramework="net40-Client" />
</packages> 

Upvotes: 42

RickIsWright
RickIsWright

Reputation: 121

If you open the references folder and locate system.data.entity, click the item, then check the runtime version number in the Properties explorer, you will see the sub version as well. Mine for instance shows v4.0.30319 with the Version property showing 4.0.0.0.

Upvotes: 11

Marcel
Marcel

Reputation: 15722

To answer the first part of your question: Microsoft published their Entity Framework version history here.

Upvotes: 18

KristoferA
KristoferA

Reputation: 12397

There are two versions: 1 and 4. EFv4 is part of .net 4.0, and EFv1 is part of .net 3.5 SP1.

Yes, the config setting above points to EFv4 / .net 4.0.

EDIT If you open the references folder and locate system.data.entity, click the item, then check the runtime version number in the Properties explorer, you will see the sub version as well. Mine for instance shows runtime version v4.0.30319 with the Version property showing 4.0.0.0. The EntityFramework.dll can be viewed in this fashion also. Only the Version will be 4.1.0.0 and the Runtime version will be v4.0.30319 which specifies it is a .NET 4 component. Alternatively, you can open the file location as listed in the Path property and right-click the component in question, choose properties, then choose the details tab and view the product version.

Upvotes: 87

Related Questions