Rod
Rod

Reputation: 421

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?

Upvotes: 4

Views: 2136

Answers (2)

Rich
Rich

Reputation: 6561

This works with EFCore 9:

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

It returns 9.0.0

Upvotes: 1

Rod
Rod

Reputation: 421

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

Upvotes: 4

Related Questions