Using Entity Framework 6 with EntityKey - entity-framework

I am trying to upgrade a big data project from EF 5 to EF 6. But when I run the code generation in EF6 tool the references to the related tables are no longer there.
So the following line of code no longer works.
dbTradeAllocation.ChargeTypeReference.EntityKey = new EntityKey("ICEEntities.SystemData", "ID", TradeAllocation.ChargeType);
Does anyone know if EntityKeys are still supported in EF6 ?
Thanks Paul

EntityKey is supported in EF6. However you cannot run EF5 code generation in EF6 - it won't work since there were changes in namespaces. I touched a little bit on this in my blog post about changes to EF Tooling in VS2013 - you can find the blog post here. If you want to use EntityObject/ObjectContext entities in EF6 you need to use EntityObject generator for EF6 which you can get from VS Gallery (note it requires .NET Framework 4.5 on the dev box).

Related

Upgrading Entity Framework

I have a Data Access Layer solution built in Visual Studio 2010. It uses Entity Data Model (.edmx files) to create object models of the data.
It is built with .Net 3.5 framework so I assume this is also version 3.5 of Entity Framework?
We use a number of TVFs to return datasets and unfortunately EF 3.5 does not provide access to TVFs. So we have has to build tsql views that call those TVFs.
Is it possible to upgrade this solution to EF 6 and use TVFs? What are the steps involved?
Microsoft has release a guide to do. You find it here:
https://msdn.microsoft.com/en-us/data/upgradeef6.aspx
It involves getting the latest assemblies and do some modifications in order to run. It seems upgrading from an older version is a little harder than from a new version.

Problems upgrading to EF 6.0. Missing EntityStoreSchemaGenerator

We have some code that utilizes the EntityStoreSchemaGenerator to auto-generate an entity model from a database.The code is based on the EdmGen2 code from here:
http://archive.msdn.microsoft.com/EdmGen2/Release/ProjectReleases.aspx?ReleaseId=4216
This has worked well in previous versions of the EntityFramework, However; in EF 6.0.1 the code no longer compiles.
It seems that the support for generating models on the fly has been removed in the latest EF version. Can anyone confirm this?
Is there an alternative solution to generate the model classes on the fly, from code, available in EF 6.0?

Entity Framework Pre-Generated View on Assembly

I just started using EF 6 and I noticed that the first execution takes more time because it needs to be compiled, so I researched and found that you can pre-generate the view.
I used EF Power Tool to generate the view: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/
It's a dll, and I'm building using the option Embed in Output Assembly.
The problem is that even though I have the view.cs when I execute the first query I have the same delay, so it seems that my library is not using the pre-generated view.
What could be wrong? I'm passing the connection to the entity using an EntityConnectionStringBuilder returning a EntityConnection object.
Also I tried changing the view.cs to Embedded Resource, since with Compile I did not have any changes, in both ways I still have the first time delay.
I'm sure I'm missing something, but not sure what.
Thanks in advance,
Lucas.
EF5 views will not work with EF6 (in addition to that there are some issues with EF6 Beta 1 and EF6 RC1 which prevent using views with EF6 - these issues should be fixed for EF6 RTM). I created a T4 template for generating views for EF6 - you can find more details here - again due to the problems above the views generated by the template will not work for EF6 RC1. If you absolutely think you need it you can try the version from my github - it was updated to work with EF6 RTM and also works with nightly builds.
Anyways, I am pretty sure that this is actually not view generation that are causing the issues (actually the performance of view generation in EF6 has been greatly improved). We recently found a few performance issues (see 1674 and 1662) that are affecting start up time and we are looking at these.
EDIT
The version of the template that works with EF6 RTM (6.0.0.0, 6.0.1.0) has been published to the VS Gallery

How to upgrade from Entity Framework 4.3 to EF 5

Currently we are working on the EF 4.3 . We would like to upgrade it to EF5. I have google the upgrade process steps, but I did not get any result. Please help me..!
Thanks.. :)
Here are two links for you of content I've created on EF4.3 to EF5:
article: Moving Existing Projects to EF 5
http://msdn.microsoft.com/en-us/magazine/jj618295.aspx
video: Entity Framework 5 Enums and Moving Solution from EF 4.3
http://thedatafarm.com/blog/data-access/video-entity-framework-5-enums-and-moving-solution-from-ef-4-3/
hth
julie

Entity Framework - Contains Method

Someone has an answer to this missing feature in Entity Framework. Does anyone have a solution to the missing Contains method in Entity Framework that works? I've tried a number of those on here and through Google, but none of them seem to actually work.
You may consider using EF 4.0 it's implemented there also StartsWith, EndsWith and many others.
ADO.NET Blog
As it was already answered, Entity Framework 4.0 Beta 2 has support for this method, but it requires Visual Studio 2010 Beta 2 to be downloaded.
In Visual Studio 2008 SP1 you can either use manual LINQ expressions construction, like it is described here, or Entity SQL, like we have already recommended here.