2

Closed

Update DbContext templates to generate EF6 code

description

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?

e.g.
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 Tue at 12:15 AM by lajones
Verified - this works on both VS2012 and VS vNext.

comments

RoMiller wrote Jan 23 at 11:58 PM

**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 at 4: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 at 8: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 at 4: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 at 5: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 at 10:39 PM

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

BriceLambson wrote May 3 at 3:20 PM

Fixed with commit 0d5f92b40a5f (EFDesigner repo)