Update DbContext templates to generate EF6 code


Using EF6. Database first.

In designer right click and select "Update model from database", select any stored procedure and then try building my project in VS2012 results in a compilation error in the auto generated DbContext class.

Looks like incorrect parameter type is being passed?

public virtual ObjectResult<SelectSystemUserAll_Result> SelectSystemUserAll(Nullable<System.Guid> user_Id)
        var user_IdParameter = user_Id.HasValue ?
            new ObjectParameter("User_Id", user_Id) :
            new ObjectParameter("User_Id", typeof(System.Guid));

        return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<SelectSystemUserAll_Result>("SelectSystemUserAll", user_IdParameter);
Error is:
Error 7 Argument 2: cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter[]' at etc
Closed May 21, 2013 at 1:15 AM by lajones
Verified - this works on both VS2012 and VS vNext.


RoMiller wrote Jan 24, 2013 at 12:58 AM

EF Team Triage: Assigning to a member of the EF team for further investigation. Once we have investigated the issue we will decide whether to fix it and if so, which release to fix it in.

moozzyk wrote Jan 24, 2013 at 5:53 PM

EF6 was first shipped after VS2012 so the designer in VS2012 is not aware of changes made in EF6 - especially integrating all the code base in just one assembly - EntityFramework.dll. The consequence of moving the code to EntityFramework.dll is that in EF6 types (even though mostly named as they were before) live in a different assembly and a different namespace. Since VS2012 is not aware of this it is adding the reference to System.Data.Entity.dll and generates the code that uses namespaces for the types that live in System.Data.Entity.dll and not in the EntityFramework.dll as it would for EF5.
We are working on moving the EFDesigner to open source and adding support for EF6. Until this is done you should be able to use VS2012 designer for EF6 projects but you will have to do some manual steps. I blogged about this a while ago - here is the link to my blogpost: http://blog.3d-logic.com/2012/12/15/entity-framework-6-and-modeldatabase-first/

MadPierre wrote Jan 28, 2013 at 9:13 AM

Thanks for the explanation moozzyk. I'd rather avoid "manual steps" if I can. They will only lead to confusion and be a pain for myself and other developers that work on teh project. Maybe I should try EF5 for now?

Any ideas on timescales for the designer update for VS2012?

moozzyk wrote Jan 28, 2013 at 5:44 PM

@MadPierre - the manual steps are just work-arounds. The work on EF6 capable designer is in progress but we don't have any dates to share at this point.

ajcvickers wrote Mar 2, 2013 at 6:50 PM

Pawel already did the investigation and responded. Changed the title to reflect the work that needs to be done in the templates for EF6. Ideally the templates will use the new function import APIs if they make it into EF6. If not, the templates should be updated to use the appropriate namespaces.

RoMiller wrote Mar 7, 2013 at 11:39 PM

EF Team Triage: We have to do this as part of the designer work in EF6.

BriceLambson wrote May 3, 2013 at 4:20 PM

Fixed with commit 0d5f92b40a5f (EFDesigner repo)

palanimvel wrote Jun 19, 2013 at 6:54 AM

Temporary fix for this problem.
Go to "yourContext".Context.tt file.

Before :

using System;

using System.Data.Entity;
using System.Data.Entity.Infrastructure;
if (container.FunctionImports.Any()) {


using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;


After Edit :

using System;

using System.Data.Entity;
using System.Data.Entity.Infrastructure;
if (container.FunctionImports.Any()) {


using System.Data.Entity.Core.Objects;
//using System.Data.Objects;
//using System.Data.Objects.DataClasses;
//using System.Linq;


NOTE :- This is for just temporary fix to develop EF 6.

bcbeatty wrote Oct 31, 2013 at 10:21 PM

This is still happening in EF 6.0.1 on VS2010

moozzyk wrote Oct 31, 2013 at 11:08 PM

VS2010 tooling does not support/is not aware of EF6. There is a standalone version available for download for VS2012 which is a counterpart of the version VS2013 ships with.

JD_BuckSavage wrote Nov 7, 2013 at 4:12 PM

Just an FYI: The fix to the T4 template above is still required if you have an existing .edmx file and open a solution that was created in VS2012 (prior to the tooling being released) and then opened in VS2013. I suspect that this is expected behavior but the modification of the .tt file is still necessary.

laduran1 wrote Feb 6, 2014 at 9:03 PM

laduran wrote Feb 6, 2014 at 9:04 PM