Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Facing Issue with Entity Framework Code First Approach Stored Procedure mapping

$
0
0

Hi,

I'm calling a stored procedure in entity framework code first approach. Basically I have four columns for my table but using stored procedure I'm only returning two columns. As, im returning only two columns. I'm getting following error:

An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: The data reader is incompatible with the specified 'CodeFirstDepartment.Models.Department'. A member of the type, 'Id', does not have a corresponding column in the data reader with the same name.

If I use the same stored procedure and return all columns its working fine. 

Is it something to do with mapping.

Following is  my code:

DepartmentContext db = new DepartmentContext(); 
SqlParameter param1 = new SqlParameter("@FilterExpression", "Sandeep"); 
var list = db.Department.SqlQuery("sp_test_Ef @FilterExpression", param1).ToList(); 

Any help would be appreciated. 

Thanks,

Sandeep


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>