Entity Framework Tutorial
Lesson 31 of 69 · Part 8 Using stored procedures with entity framework code first approach · Database
Part 8 Using stored procedures with entity framework code first approach
Text version of the video
http://csharp-video-tutorials.blogspot.com/2014/05/part-8-using-stored-procedures-with.html
Slides
http://csharp-video-tutorials.blogspot.com/2014/05/part-8-using-stored-procedures-with_14.html
Entity Framework – All Text Articles
http://csharp-video-tutorials.blogspot.com/2014/05/entity-framework-tutorial.html
Entity Framework – All Slides
http://csharp-video-tutorials.blogspot.com/2014/05/entity-framework-tutorial-slides.html
Entity Framework Playlist
Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd
In this video we will discuss using stored procedures to perform Insert, Update and Delete operations using entity framework code first approach.
public class EmployeeDBContext : DbContext
{
public DbSet[Employee] Employees { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// This line will tell entity framework to use stored procedures
// when inserting, updating and deleting Employees
modelBuilder.Entity[Employee]().MapToStoredProcedures();
base.OnModelCreating(modelBuilder);
}
}
Entity Framework will create the following stored procedures automatically
Employee_Delete
Employee_Insert
Employee_Update
The default, naming convention for the stored procedures
INSERT stored procedure – EntityName_Insert
UPDATE stored procedure – EntityName_Update
DELETE stored procedure – EntityName_DeleteNote: Insert Stored procedure should return the auto-generated identity column value