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?
I ended up getting the assembly version since I didn't find another way.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With