Code First 4.1 : Using Stored Procedure to Insert Data

Code First 4.1 : Using Stored Procedure to Insert Data

  • Comments 4

Code First in Entity Framework does not support Stored Procedure by default. As there is no designer we cannot even map our stored procs to the entity. There are a many scenario we have seen where we are bound to use stored procedure for any database modifications (insert/update/delete). Here is how we can use stored procedure.

image

This would finally call the Stored Procedure.

The stored proc used here is very simple

ALTER PROCEDURE [dbo].[stp_InsertEmp]
(
	@Name as VARCHAR(50)
) AS
 
	INSERT INTO Emps(Name) VALUES(@Name)

Namoskar!!!

Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post
  • if I have some object to return, How I can do?

  • its not clear to me. how can we use blog or add comments. actually i m using it for the very 1st time.

  • Thanks, this is great. But please, next time don't post an image, post code that can be copied!

  • it should be the same as you do in TSQL

Page 1 of 1 (4 items)