Part 8 Using stored procedures with entity framework code first approach

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

Entity Framework - All Text Articles

Entity Framework - All Slides

Entity Framework Playlist

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses

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
Рекомендации по теме
Комментарии
Автор

Thanks for very useful video!
It create insert, update, delete storeProcedure very well.
Can you show me how to create a Get procedure?

Thanks.

kimthanhly
Автор

Getting error does not contain a definition for 'MapToStoredProcedures' and no accessible extension method 'MapToStoredProcedures' accepting a first argument of type could be found (are you missing a using directive or an assembly reference?)". I am using EF 5.0

thevoyagerguide
Автор

hola hdleon tendrás un link de como consumir un SP con EF desde NET6 pero que el store me retorna más de un conjunto de datos. Gracias.

juliocarrerac
Автор

Thank you very much for this video. Please take a class of using stored procedures with entitiy framework code first on MVC

ManojBhusal
Автор

you are great person and your videos are too good
sir where did you learn all these things ?
any ref would be great help ....

AfzaalMunir
Автор

Useful information and Great job.Can we pass data from WCF/API controller services to gridview ? Looking forward for your ASP.Net WebAPI video series.

sivag
Автор

I'm sorry sir, why is is generating 3 stored procedures only, I watch 4 implementations: Get, Update, Delete and Insert. I like very much your videos. you've got another subscriber

johnkoutman
Автор

nice video ... Plz also upload LINQ video's

jiturcm
Автор

sir u r doing great job god bless u ... please upload LINQ VDO

priyamahindrakar
Автор

how you are generated database name in sql management studio. For my case when i run this code it is catching first database that i created and generating the table . Thanks advance

MAHOSSAN
Автор

Thanks for the tutorial, it's amazing!
Btw, the delete procedure dows not work, it throw me an error(nullreference)

pennaverdeful
Автор

error when trying to configure the data source on the entitydatasource. it says: This version of the Entity Data Source Wizard is only compatible with EntityFramework 5. If you're not using EntityFramework 5 you can configure the control by editing the markup on the page. The page editor has IntelliSense support for ASP.Net Controls. If you're using Entity Framework 6 you should also be using the EF6-compatible version of the Entity Data Source control, available as the package in NuGet.

i did how it suggested me, but still don't work... I'm usign EF 6.1.3 in VS 2015... please guide me how to fix this problem

arianitonline
Автор

how manage concurrency in entity framework?

gkmishra
Автор

how to use this instead of object data source and in MVC

manideepkumar
Автор

Good job. Clicking the delete button, I get an error message: value cannot be null, parameter name: entity

taiwobabalola
Автор

I Have an Error in cant found it !!
using System.Data.Entity;

murtadael-amin