Entity Framework - Contains Method - entity-framework

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.

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.

Using Entity Framework 6 with EntityKey

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

Missing template for Db context generator for Visual Studio 2010

I have Vs2010 ultimate. I installed asp.net mvc 4 and EF 5 that was part of it.
There is no db context generator template for EF 5 for visual studio 2010. Only for the RC of the next version.
Short of installing vs 2012. What are my options?
You can find the generators in VS gallery - EF 5.x DbContext Generator for C# or EF 5.x DbContext Generator for C# Web Sites; both are intended for VS2012 but perhaps you'll be able to make them work with VS2010.
Here is an alternate way to accomplish this:
In the Add New Item dialog box, at the section on the left where you choose the type of template, click on Online Templates and then perform a search for what you need.
In this case you would search for DbContext Generator, you will get many listings that look like EF 5.x DbContext Generator for C# or EF 4.x DbContext Generator for C#. Select the appropriate version based on the version of EF you have installed.
This is intended for and works right from within VS 2010 so you don't have to man handle anything. You should be all set.
Cheers!

How to get spatial types working in EF?

I have a table with a SQL Geometry column. Now I'm trying to work with EF but the mapper doesn't want to include it (it should be supported by now, as I saw here). Also, I can't find the Spatial Types in the EF Designer as I saw here.
I have done so far:
PM> Install-Package EntityFramework –IncludePrerelease
'EntityFramework 5.0.0-beta2' already installed.
MyProject already has a reference to 'EntityFramework 5.0.0-beta2'.
and after this, the version of the referenced EnitiyFramework.dll is:
4.4.0.0
Sadly, if you are targeting .net 4, it would not work: Some features are only available when writing an application that targets .NET 4.5. This includes enum support, spatial data types, table-valued functions and the performance improvements. If you are targeting .NET 4.0 you still get all the bug fixes and other minor improvements.
source: http://blogs.msdn.com/b/adonet/archive/2012/03/22/ef5-beta-2-available-on-nuget.aspx
Also, if you are targeting 4.5, look here: How to get enums working in mvc4 with Entity Framework 5 Beta 2?

What happens in a .Net 4 app when referencing .net 2 assemblies?

I have an application I want to upgrade to .NET 4, but I have a couple 3rd party assemblies that reference the .NET 2 BCL.
I seem to remember reading something that says they should play nice, but I can't find any documentation on the subject. ( I think my question posed to Google is just too broad, with not enough .Net 4 material out there yet )
Can anyone help me find documentation on what will happen in this case?
If I'm reading Scott Guthrie's post, Multi-Targeting Support (VS 2010 and .NET 4 Series), correctly then that will work fine.
Of Interest?: .NET 4.0 project reference 2.0 assembly
The .NET Framework 4 works side by side with older Framework versions. Applications that are based on earlier versions of the Framework will continue to run on the version targeted by default.
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7
I wanted to reference StructureMap in one of my class libraries. Orginally it was created by VS2010 to use the .NET 4 client profile. Turns out, I had to changed this to the full .NET 4 framework, otherwise structuremap would not be recognized.