Hi
If you will create the Data model in EF using general approach then you will be not able to fetch data from SP in EF.
For fetching data from SP using EF. we can do like this
Step 1 : Add the SP and Table Name in Data Model like this
Step 2: In the data model designer, right-click on Model Browser then go to storeprocedure
Step 3: click on “Add Function Import” and configure the SP maping like image
Step 4: Click on save all and build the application
Step 5: Write the code in code behind file like this
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { using (DatabaseModel.DatabaseEntities dc = new DatabaseModel.DatabaseEntities()) { //var query = dc.VW_tblEmp.Select(m => m); var query = dc.GetEmpName(); Grid1.DataSource = query; Grid1.DataBind(); } } }
Note: Here i hope that you are aware of doing configuration on model in EF.