如何在WinForms应用程序中检索实体框架的版本[重复]

时间:2021-04-30 00:11:09

Possible Duplicate:
How to get current EF version

可能重复:如何获取当前的EF版本

In my windows forms application, I want to display the Entity Framework version being used by the applications .edmx files. Is it possible to get the Entity Framework version from the app.config file or the .edmx file in C#?.

在我的Windows窗体应用程序中,我想显示应用程序.edmx文件使用的实体框架版本。是否可以从app.config文件或C#中的.edmx文件中获取Entity Framework版本?

2 个解决方案

#1


2  

You can get it like this:

你可以这样得到它:

Assembly assembly = Assembly.LoadFrom("System.Data.Entity.dll");
Version ver = assembly.GetName().Version;

#2


1  

The EDMX file version isn't related to Entity Framework version, although there's a version. Probably best is to simply check the version of EntityFramework.dll (assuming you're using more or less current version(s)) that's loaded in your application. I.e. AppDomain.CurrentDomain.GetAssemblies might be helpful.

EDMX文件版本与Entity Framework版本无关,尽管有一个版本。可能最好只是检查应用程序中加载的EntityFramework.dll的版本(假设您使用的是更多或更少的当前版本)。即AppDomain.CurrentDomain.GetAssemblies可能会有所帮助。

#1


2  

You can get it like this:

你可以这样得到它:

Assembly assembly = Assembly.LoadFrom("System.Data.Entity.dll");
Version ver = assembly.GetName().Version;

#2


1  

The EDMX file version isn't related to Entity Framework version, although there's a version. Probably best is to simply check the version of EntityFramework.dll (assuming you're using more or less current version(s)) that's loaded in your application. I.e. AppDomain.CurrentDomain.GetAssemblies might be helpful.

EDMX文件版本与Entity Framework版本无关,尽管有一个版本。可能最好只是检查应用程序中加载的EntityFramework.dll的版本(假设您使用的是更多或更少的当前版本)。即AppDomain.CurrentDomain.GetAssemblies可能会有所帮助。