Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot implicitly convert type System.Data.Entity.Core.Objects.ObjectResult to System.Data.Objects.ObjectResult

I am trying to update an EDMX Stored Procedure and I am getting this error:

Cannot implicitly convert type System.Data.Entity.Core.Objects.ObjectResult<X> to System.Data.Objects.ObjectResult<X>

I am using Visual Studio 2012.

like image 514
Akira Yamamoto Avatar asked Jul 16 '14 16:07

Akira Yamamoto


2 Answers

I had the error and none of these solutions worked (I was already using System.Data.Entity.Core.Objects, it was also in the context.tt, etc).

I eventually realised the problem lay between the keyboard and the chair. The stored proc finished with a select, but I was trying:

MyStoredProc_Result r = dbcontext.MyStoredPoc();

Instead of

MyStoredProc_Result r = dbcontext.MyStoredPoc().FirstOrDefault();
like image 119
SteveCav Avatar answered Oct 31 '22 03:10

SteveCav


Open the context.tt file in XML mode and change

using System.Data.Objects;

to

using System.Data.Entity.Core.Objects;
like image 12
Sachin Verma Avatar answered Oct 31 '22 02:10

Sachin Verma