Determine version of Entity Framework I am using? - entity-framework

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" />

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.

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.

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>

if you are using EF core this command below could help
dotnet ef --version

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

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.

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

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;
}

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

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:
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.
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

Related

Cannot upgrade Ninject to latest version in Nuget

I have a ASP.NET WebForms application that uses some Ninject packages, but I am stuck at a certain version. When I try to upgrade to the latest version, I get "Unable to resolve dependencies" issues.
The packages in question are:
Package InstalledVer LatestVer
------------------------------------------------------
Ninject v3.2.2 v3.3.4
Ninject.Web v3.2.1 ✔ v3.2.1
Ninject.Web.Common v3.2.3 v3.3.1
Ninject.Web.Common.WebHost v3.2.3 v3.3.1
If I try updating Ninject, I get:
Unable to resolve dependencies. 'Ninject 3.3.4' is not compatible with
'Ninject.Web 3.2.1 constraint: Ninject (>= 3.2.0 && < 3.3.0)'
but Ninject.Web is already at the latest version!
Should I change the Dependency behaviour of Ninject.Web or would this be unsafe? If I do, what should I change the Dependency behavior to?
Thanks
Okay, so this is how to fix:
Remove the Ninject.Web package completely. This package is no longer required as it is now integrated into Ninject.Web.Common (well, version v3.3+ anyway)
Update the packages Ninject, Ninject.Web.Common and Ninject.Web.Common.WebHost. These should now upgrade okay. For me, they are both v3.3.1.
As part of the package upgrade a new file App_Start\Ninject.Web.Common.cs will have been added. This is just a rename of the existing App_Start\NinjectWeb.Common.cs so either [a] delete the new file or [b] migrate over your Ninject module registrations and remove the old file.
In web.config, you should now remove the OnePerRequestModule module:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="OnePerRequestModule" type="Ninject.Web.Common.OnePerRequestHttpModule" />
</modules>
</system.webServer>
This is because this module, is registered dynamically on loadup in the App_Start\Ninject.Web.Common.cs file's Start() method:
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
bootstrapper.Initialize(CreateKernel);
}
If you don't remove this entry from web.config then you can expect a type exception when launching your application, not least because as part of the version update, the class has moved from the Ninject.Web.Common namespace to Ninject.Web.Common.WebHost.
You can also remove the file App_Start\NinjectWeb.cs for the same reason (registering NinjectHttpModule)
If OnePerRequestHttpModule doesn't resolve in App_Start\Ninject.Web.Common.cs then add the following using statement to the file using Ninject.Web.Common.WebHost; (I think this is a missing reference in v3.3.1 of the package.
Hope this helps others.

Entity Framework 7 with Universal Windows Platform Add-Migration

I'm trying to implement Universal Windows Platform application with EntityFramework and SQLite (according to: http://ef.readthedocs.org/en/latest/platforms/uwp/getting-started.html) but I have problem with Add-Migration command.
Here is my setup:
Visual Studio 2015 Update 1
EntityFramework.SQLite: "7.0.0-rc1-final"
Error that I got while adding migrations is:
Could not load file or assembly 'System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Thanks in advance for your help!
It is clearly that you miss a dll "System.Collections.Immutable, Version=1.1.36.0" in your project.
To solve this problem, you can open the Nuget tool, and search for System.Collections.Immutable, then in the "Version" label select the Version 1.1.36, by default it is the latest version 1.1.37.
You can also try to update your VS tool, this possible may also solve your problem.

How to ensure that the OpenXml assembly doesn't cause a conflict with SpreadsheetLight?

I Nugot SpreadsheetLight. To subsequently use it, I need to add the following usings:
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
using SpreadsheetLight;
For the first two ("DocumentFormat") to be recognized, I needed to also NuGet Microsoft's "Open XML Format SDK"
I got the latest version of that, 2.5
However, even then, I got an err msg about needing a reference to it:
The type 'DocumentFormat.OpenXml.Spreadsheet.InlineString' is defined in an assembly that is not referenced. You must add a reference to assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
This line of SpreadsheetLight code provoked that msg:
sl.SetCellValue("A1", true); // "sl" is an SLDocument
So, I removed the reference that I had NuGot (version 2.6.0.0, Runtime Version v4.0.30319) from my project, and then added back the reference by browsing to C:\Program Files(x86)\Open XML SDK\V2.0\lib and selecting "DocumentFormat.OpenXml.dll"
I then got a compiler Warning:
Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
I noticed that the DLL I added from the file system was version 2.5.5631.0, and the one that had been NuGot and installed as a reference that way was version 2.6.0.0 The Runtime Version was different, too (v4.0.30319 was installed by NuGetting "Open XML Format SDK", but the version of the DLL I manually added is 2.5.5631.0, Runtime Version v4.0.30319
According to this, I gathered that I should edit the .csproj file by changing <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> to true - but AutoGenerateBindingRedirects does not exist there.
I don't know whether I should add it, and if so (in which "block"). I prefer to play it safe and assuage the Warning engine. How can I ensure that the OpenXml assembly doesn't cause a conflict?
Assuaging that Warning (so that it rides off into the sunset) is a matter of downgrading the version of DocumentFormat.OpenXML to Version 2.0.5022.0 (Runtime Version v2.0.50727)
I found this out because this code from the "Hello World" example here.
SLDocument sl = new SLDocument();
sl.SetCellValue("A1", true);
. . .
...failed on the first line with, "Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies"
And so, since it's expecting version 2.0, I removed my 2.5.5631.0 of that file and then NuGot "OpenXML SDK 2.0" in its stead. That is Version 2.0.5022.0 and Runtime Version v2.0.50727
So: No need to update the project file with an arcane boolean property after all.
It kind of gives me the fantods, though, to have to use an older version of an assembly.
UPDATE
The need to "go retro" with DocumentFormat.OpenXml is corroborated here.
One can solve the problem by redirection of DocumentFormat.OpenXml from Version 2.0.5022.0 to more recent version, for example to version 2.5.5631.0. To do this one should add in web.config the new <dependentAssembly> item:
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.5022.0" newVersion="2.5.5631.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
...
<configuration>
Spreadsheetlight works with DocumentFormat.OpenXml 2.5 since version 3.4.5:
"Version 3.4.5
- SmartTags is now removed from consideration (not so smart now, are you? ;). Which means the code is now ready for Open XML SDK 2.5! And yes, it now works with Open XML SDK 2.5 (have I mentioned that? lol)"
quote from: https://www.nuget.org/packages/SpreadsheetLight/

Upgrade to EF6 on .net4 - System.Data.MetadataException: Schema specified is not valid

I have an asp.net website running under .net v4.
I have upgraded from Entity Framework v5 to v6.02 and all worked fine running locally on IIS express and .net4 using the EntityFramework v4 dll provided by nuget.
I publish to my hosting company and get the error below. Upgrading to .net4.5 might help, but this is not an option on my provider at the moment.
Any suggestions?
System.Data.MetadataException: Schema specified is not valid. Errors: BkkpsModel.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'. BkkpsModel.csdl(2,32) : warning 0005: Could not find schema information for the attribute 'Alias'. BkkpsModel.csdl(2,98) : error 0005: The 'http://schemas.microsoft.com/ado/2009/02/edm/annotation:UseStrongSpatialTypes' attribute is not declared. BkkpsModel.csdl(2,2) : error 0010: The element Schema in namespace http://schemas.microsoft.com/ado/2009/11/edm was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm, http://schemas.microsoft.com/ado/2007/05/edm, http://schemas.microsoft.com/ado/2008/09/edm.
You created an EDMX file with Entity Framework 6 but you using it with Entity Framework 5.
Entity Framework 6 uses EDMX file with version 3.0 but Entity Framework 5 does not support it.
You must repair your EDMX file from version 3.0 to version 2.0
The easiest way to do that is open EDMX in Visual Studio 2012 project with Entity Framework 5 or older. The entity data model designer show error: unable to display file. The file references an XML namespace that is inconsistent with the target framework of the project. Than click the modify link and the designer automaticly repair your EDMX file.
OR:
1. open your EDMX file as XML Editor
2. change the following elements:
from:
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
to:
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
from:
xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl"
to:
xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl"
from:
xmlns="http://schemas.microsoft.com/ado/2009/11/edm"
to:
xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
from:
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
to:
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
... for all inconsistent xmlns
Another way of achieving what Cyrus said (downgrading from edmx v3 to ednx v2) is in the answer for another question:
EDMX .NET 4.5 to 4.0?
In my case, I rebuilt the Solution and the edmx compiled, changed a bunch of DLLs and PDBs and I was able to open the EDMX just fine. Hope that helps.
Vishwa

TortoiseSVN issue tracker plugin built - but not implemented

I've read all the info of how to build an issue tracker plug-in in C# for TortoiseSVN.
I done that, building a class library with integration to my issue tracking (SalesForce).
I don't know how to install it to TortoiseSVN itself.
I've created a setup for the solution and I can install it (like JIRA solution that I found online).
I don't know what is missing.
Update:
I did what you wrote, made sure everything is correct.
I don't get the name of the provider, but the GUID, and an error:
alt text http://img339.imageshack.us/img339/8558/sfsvnerror.jpg
what can it be?
1) You need to make sure that you have the right CLSIDs registered in the registry - so my installer inserts the following (fake) values:
(This, I think should be the equivalent of running RegASM as detailed at the bottom of the issue-tracker-plugins.txt file.
Installer Registry Changes Image http://img291.imageshack.us/img291/1618/registryinstaller.png
You should be able to import this registry file to get you started:
(You will probably have to dynamically update the CodeBase location, based on where the dll is installed to)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}]
#="FogBugzPlugin.MyPlugin"
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\Implemented
Categories]
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\Implemented
Categories{3494FA92-B139-4730-9591-01135D5E7831}]
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\Implemented
Categories{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\InprocServer32]
#="mscoree.dll"
"ThreadingModel"="Both"
"Class"="FogBugzPlugin.MyPlugin"
"Assembly"="MyAssemblyName,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31286c9d1d5aa00a"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Program
Files/folder/AAAAAAAAAAAAA/MyAssemblyName.dll"
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\InprocServer32\1.0.0.0] "Class"="FogBugzPlugin.MyPlugin"
"Assembly"="MyAssemblyName,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31286c9d1d5aa00a"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Program
Files/folder/AAAAAAAAAAAAA/MyAssemblyName.dll"
[HKEY_CLASSES_ROOT\CLSID{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}\ProgId]
#="FogBugzPlugin.MyPlugin"
2) You need to make sure that the user gets the BugTraq Associations added to the registry:
[HKEY_CURRENT_USER\Software\TortoiseSVN\BugTraq Associations\0]
"Provider"="{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}"
"WorkingCopy"="c:\"
"Parameters"=""
(This can also be done manually by the user by going to TSVN -> Settings -> Hook Scripts -> Issue Tracker Integration -> Add
Where "{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}" is the GUID of the provider that you created.
All being well, the plugin should now be available to the user. when they open the commit dialog.
Update:
Troubleshooting the "Provider Shows As GUID" Issue seen above...
OK... so assuming your provider GUID is
{0DA7E319-1DCE-4A94-65555B5B6CE5}
You should check:
Your plugin implements IBugTraqProvider and IBugTraqProvider2 and has the GUID applied to it:
namespace FogBugzPlugin
{
[ComVisible(true),
Guid("0DA7E319-1DCE-4A94-65555B5B6CE5"),
ClassInterface(ClassInterfaceType.None)]
public class MyPlugin : IBugTraqProvider, IBugTraqProvider2
So now you should have:
GUID: 0DA7E319-1DCE-4A94-65555B5B6CE5
PluginName: FogBugzPlugin.MyPlugin
Go to regedit and have a look and see what you have in the registry. It should be along the lines of:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}]
#="FogBugzPlugin.MyPlugin"
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\Implemented Categories]
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\Implemented Categories\{3494FA92-B139-4730-9591-01135D5E7831}]
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\InprocServer32]
#="mscoree.dll"
"ThreadingModel"="Both"
"Class"="FogBugzPlugin.MyPlugin"
"Assembly"="FogBugz2Tortoise, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31286c9d1d5aa00a"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Program Files/folder/FogBugz2Tortoise/FogBugz2Tortoise.dll"
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\InprocServer32\1.0.0.0]
"Class"="FogBugzPlugin.MyPlugin"
"Assembly"="FogBugz2Tortoise, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31286c9d1d5aa00a"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Program Files/folder/FogBugz2Tortoise/FogBugz2Tortoise.dll"
[HKEY_CLASSES_ROOT\CLSID\{0DA7E319-1DCE-4A94-65555B5B6CE5}\ProgId]
#="FogBugzPlugin.MyPlugin"
You should also have the ProgID / CLSID entry directly under HKCR:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\FogBugzPlugin.MyPlugin]
#="FogBugzPlugin.MyPlugin"
[HKEY_CLASSES_ROOT\FogBugzPlugin.MyPlugin\CLSID]
#="{0DA7E319-1DCE-4A94-65555B5B6CE5}"
Hope this helps - I'd check the last point first.