I'm trying to use LINQPad 4 (the latest beta) with Entity Framework POCO classes. I take the normal path of creating a new connection and then selecting "Entity Framework DbContext POCO(4.1) and then selecting my he assembly holding my classes. When I do so I get the following message
"Could not load file or assembly EntityFramework. Version=4.1.O.O,
Culture= neutral, PublicKeyToken=b77a5c561934e089 or one of its dependencies.
The system cannot find the file specified."
I'm able to load the assembly from my application just fine. What gives? It seems a bit different from the previous problem like this reported in the CTP.
I had the same problem today, this is how I solved it:
Apparently the LINQPad 4.36.3 requires in some way Entity Framework 4.2 :/
It was released last week: ADO.NET blog
What I did is:
Installed EF4.2 via NuGet
Rebuilt the project
Copied all my project .dll files to LINQPad folder (including the 4.2 EF.dll)
I read here that I need to add something to the LINQPad.exe.config file but it was already there..
[At this point I tried removing that assembly redirect and ran it against my 4.1 dll, did not work, was still looking for 4.2]
Closed VS and uninstalled EF4.1
Thats it, after that both my project is now running on 4.2 and LINQPad works as well.
Related
I am trying to use EF7 with the old project type (csproj)
If I run Add-Migration in package manager, it complains that it cannot find package EntityFramework. I guess it is looking for the EF6 EntityFramework project, since such a project does not exist anymore? How can I force it to use EF7 Add-Migration cmdlet?
I have tried running ef commands with dnx in the "wrap" folder, but that seems needlessly complicated and it doesn't work (it cannot find any framework dependencies at all)
Any ideas?
Have you installed EntityFramework.Commands? https://www.nuget.org/packages/entityframework.commands
Also, using EF6 and EF7 in the same solution is going to cause some problems. It's probable that Add-Migration failed because you are actually running the EF6 command. Check if the command Use-DbContext exists, which is new to EF7.
I am using TFS 2010 and VS 2012.
I failed in my attempt to upgrade MVC4 to MVC5. I thought I rolled back my project OK in TFS but my builds fail because the references to EF version 6 have not all been removed.
As far as I can tell I have removed EF v6 everywhere in my code. However in my build I have the following message;
Unified primary reference "EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
Using this version instead of original version "4.4.0.0" in "C:\Builds\3\solutionA\solutionA- Test\Sources\projectB\projectB\bin\Debug\projectB.dll" because AutoUnify is 'true'.
Resolved file path is "C:\Builds\3\solutionA\solutionA - Test\Sources\MVC4\solutionA\solutionA.Model\lib\EntityFramework.dll".
Reference found at search path location "{CandidateAssemblyFiles}".
So what does "AutoUnify is true" mean?
Decided to make a proper answer from our comments. I think this initial problem was an out of sync dll, from the packages folder. You re-installed EF 5 fresh were still having packages issues.
This appears to also be something with your Nuget setup. This SO article is the same error as your latest build error. Build cannot find entity framework .
In particular this article from the accepted answer sounds very similar to the issues you're having. http://msmvps.com/blogs/rfennell/archive/2011/10/17/using-nuget-and-tfs-build-2010.aspx especially to your point that it works locally, but not in the build process. Let me know if your issues seems different.
After importing a stored procedure into my datamodel the project stopped compiling.
It keeps giving me error:
The best overloaded method match for
'System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction<TicketDataModel.sp_get_orphanjobgrades1_Result>
(string, params System.Data.Entity.Core.Objects.ObjectParameter[])'
has some invalid arguments C:\Users\nikolaev\Documents\MySoft\TicketManager-06 11 2013\TicketManager\TicketDataModel\TicketDataModel\TicketEntities.Context.cs 105 20 TicketDataModel
and
`Argument 3: cannot convert from 'System.Data.Objects.ObjectParameter' to
'System.Data.Entity.Core.Objects.ObjectParameter'
C:\Users\nikolaev\Documents\MySoft\TicketManager-06 11 2013\TicketManager\TicketDataModel\TicketDataModel\TicketEntities.Context.cs 79 143 TicketDataModel`
The code in context.cs is as follows:
public virtual ObjectResult<sp_get_orphanjobgrades1_Result> sp_get_orphanjobgrades1(Nullable<System.DateTime> start_date, Nullable<System.DateTime> end_date)
{
var start_dateParameter = start_date.HasValue ?
new ObjectParameter("start_date", start_date) :
new ObjectParameter("start_date", typeof(System.DateTime));
var end_dateParameter = end_date.HasValue ?
new ObjectParameter("end_date", end_date) :
new ObjectParameter("end_date", typeof(System.DateTime));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<sp_get_orphanjobgrades1_Result>("sp_get_orphanjobgrades1", start_dateParameter, end_dateParameter);
}
I read that this may be because of EF 6 and that one needs to download VS 2012 Update 1 and/or EF 6 Tools for VS 2012. I downloaded the tools and I already have update 4 installed, but that doesn't help.
Why is this?
The problem is that your model don't know anything about new parameters. I guess that it happens when your model using EntityFramework (EF) lower version (5.0 for example), but in code you are trying to use EF 6.0.
So, you should either downgrade your code to EF 5.0, or upgrade your model to 6.0.
Upgrading model:
Open Tools -> NuGet Package Manager -> Package Manager Console;
Choose project, that contains your model as Default project on the
top of Console.
Type "Uninstall-Package EntityFramework" and press Enter;
After removing, type "Install-Package EntityFramework -version
6.0.0" and press Enter again;
Go to YourModelName.Context.cs and YourModelName.Context.tt and replace "using
System.Data.Objects; using System.Data.Objects.DataClasses;" with "using
System.Data.Entity.Core.Objects;". Also, you may need to make the
same in all files, where this problem appears.
Or you can downgrade EF version, used in your code. For this, you should do all the same in first 3 steps but in the fourth replace "-version 6.0.0" with "-version 5.0.0". The 5th step is not needed for this.
To fix this issue:
If version conflicts, install package for respective version of EF.
If version is same, change the above namespace to System.Data.Entity.Core.Objects
You can download new verions in msdn.
Download Tools for Entity Framework 6.1.0 or new versions
in http://www.microsoft.com/en-us/download/details.aspx?id=40762
Use in Package Manager Console
Install-Package EntityFramework -version 6.1.0 and enter
Restart your visual studio.
4.Check your package Manager and finish.
I just want to add that this happened to me after starting a brand new project. The issue was that I had created a new project, and then proceeded to update the Entity Framework, ASP.Net MVC, and other packages through the NuGet Package Manager. So, the code generated for my project no longer matched what I had installed.
The quickest solution for me was to just create a new project since I hadn't done any real work yet. I hope this helps somebody else out there.
My situation was a new project, and I went to nuget with Install-Package EntityFramework which installed the 6.0 version, however apparently my project was already set up with an earlier version? Not sure how, maybe the default of MVC 4.0 project...
So I had to do an Uninstall-Package -force EntityFramework followed by
Install-Package EntityFramework -version 5.0.0
Everything worked after that.
I'm experimenting with EntityFramework 4.3 using CodeFirst. I have worked with EF 4.0 ModelFirst and DatabaseFirst for about two years now and want to integrate CodeFirst into an exiting CRM Database project. (...but tried it without an existing Database!)
I am using VS 2010, VB.Net ans SQLEXPRESS Server 2008 for developing.
So I started with a NEW project using the msdn-Examples: "EF 4.2 Code First Walkthrough"
( http://blogs.msdn.com/b/adonet/archive/2011/09/28/ef-4-2-code-first-walkthrough.aspx )
and a VB.NET adaption from "Productivity Improvements for the Entity Framework"
( http://blogs.msdn.com/b/vbteam/archive/2010/06/21/productivity-improvements-for-the-entity-framework.aspx )
I quote: "That is 100% of the code you would write to get this program running. No separate model definition, XML metadata, config file or anything else is required. "
Well, that seems not to be true for my system.
I installed EntityFramework 4.3 with NuGet Packet Manager and the Reference is correctly there.
I first tried it without App.Config - adaption. I got the InvalidOperationException ... not mapped:
"The type 'CodeFirstSample.MyDataAccessDemo.Program + Product' was not
mapped."
I added a database connectionString to the app.config for my SQL Server-connection, created a database "Products" and tried again.
Same error...
What did I do wrong?
I googled a lot but couldn't find any hints.
I suppose you have some problem with Database initialization and Connection string .
It's necessary you define your database initialization strategy at starting point of your project , One example could be :
Database.SetInitializer(
new DropCreateDatabaseIfModelChanges<YourContext>());
I do recommend try some of Julie Lerman's Source code example , I assure you it 100% work with sql server 2008 express and visual studio 2008 without touching a line of code , Just hit F5 .
You have to bring Blog and Post classes out of Main class.
Please look at this post:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/84dd6851-9ee5-48a2-950b-de90cdb30cb0/
I'm running WCSF Feb 2008 along with Enterprise Library 3.1 and noticed that randomly I get the "fun"
Could not load file or assembly Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, Public ... The located assembly's manifest definition does not match the assembly reference.
Usually this wouldn't be worth mentioning on stackoverflow, but the strange thing is that the first time I fire this up it breaks, but if I close it down and simply hit F11 again - it works .... strange. Does anyone know why this might break sometimes, but not others?
The problem was related to my version of the data access DLL I was adding. I found that if I went to the following:
C:\Program Files\Microsoft Web Client
Software Factory February
2008\Microsoft Practices Library
and imported this specific data access DLL instead of the one I compiled myself from the Enterprise Library 3.1 installer, everything worked great.