Getting table data using DbContext in Entity Framework is easy, you just need to create a DbSet collection property something like this
public DbSet<PointModel> PointModels { get; set; }
But if you want to call the Stored Procedure then? Lets learn it.
To call the Stored Procedure using DbContext, there are many ways that you find using google, in my case all of them was not working. Some were like passing SqlParameter or by passing the parameter values separated by comma etc.
What worked is below.
var cloud = db.Database.SqlQuery<TagCloud>("EXEC VideoTagCloud {0}", 0);
Here,
VideoTagCloud is my stored procedure name, {0} is the first parameter place holder, similarly you can have n number of placeholder and values separated by comma.
Hope this will be helpful to someone.
Thanks
Regards,
Sheo Narayan
http://www.dotnetfunda.com