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

Call stored procedures with Entity Framework 6 code first approach in Asp.Net MVC 5

$
0
0

We are using Ado.Net for working with the database from our C# code in Asp.Net MVC. I want to work with Entity Framework, so I need to use stored procedures with it, call SP with EF. There are few examples how to use Stored Procedures with Entity Framework, but none specific for Asp.Net MVC Code First (at least I couldn't find any). They are a good start but I need something more, better information and better examples!

I have this SP:

Create Procedure spAddEmployee
@Name nvarchar(50),
@Gender nvarchar(20),
@Salary int,
@EmployeeId int Out
as
Begin
   Insert into tblEmployees values(@Name, @Gender, @Salary)
    Select @EmployeeId = SCOPE_IDENTITY()
 End

So @Name,@Salary,@Gender are input parameters, and @EmployeeId is an outpud parameter, it shows me the ID of the new added employee.

So can someone tell me how to use Entity Framework (Code-first) to call the stored procedures and with the parameters.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



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