Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current EF version

Since new Entity Framework version I got from nuget broke some of my tests, in one of my projects I want to make sure the Entity Framework version installed as reference for the entire solution is the version 4.1.10331.0

What's the best way to find out I'm referencing entity framework 4.1.10331.0 since nuget installs it per solution? Reading packages.config? Going through all the assemblies in current domain?

like image 750
Rod Avatar asked Oct 21 '25 13:10

Rod


2 Answers

I ended up getting the assembly version since I didn't find another way.

like image 146
Rod Avatar answered Oct 23 '25 04:10

Rod


This works with EFCore 9:

private static string GetEntityFrameworkVersion() =>
typeof(Microsoft.EntityFrameworkCore.Infrastructure.ProductInfo).Assembly
                .GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
                .InformationalVersion;

It returns 9.0.0 or whatever version you have installed.

like image 45
Rich Avatar answered Oct 23 '25 04:10

Rich