Part 25 Insert update delete in mvc using entity framework

preview_player
Показать описание
In this video we will discuss, selecting, inserting, updating and deleting data in mvc using entity framework. Please watch Part 24, before proceeding.

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.

We will be using tables tblDepartment and tblEmployee for this demo. You can get the sql script to create and populate these tables from Part 10 of this video series.

On the subsequent screen, select "Generate from database" option and click "Next".

On "Choose your data connection screen", click on "New Connection" button.

Specify the sql server name. In my case, I have sql server installed on my local machine. So I have set "Server Name=(local)". From "Select or enter a database name" dropdownlist, select the Database name and click "OK".

Click "Next".

On "Choose your database objects" screen, expand "Tables" and select "tblDepartment" and "tblEmployee" tables. Set "Model Namespace=Models" and click "Finish"

At this point we should have tblDepartment and tblEmployee entities generated.
a) Change tblDepartment to Department
b) Change tblEmployee to Employee
c) Change tblEmployees nvigation property to Employees
d) Change tblDepartment nvigation property to Department

Entity Container Name = EmployeeContext

Build the solution.

Step 3: Right click on the "Controllers" folder and select Add - Controller. Set
Name = EmployeeController
Template = MVC controller with read/write actions and views, using Entity Framework
Model class = Employee(MVCDemo.Models)
Data Context Class = EmployeeContext(MVCDemo.Models)
Views = Razor

Finally click "Add".

At this point you should have the following files automatically added.
2. Index, Create, Edit, Detail and Delete views in "Employee" folder.

On Create and Edit views, please delete the following scripts section. We will discuss these in a later video session.
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

At this point, if you run the application by pressing CTRL + F5, you will get an error stating - The resource cannot be found. This is because, by default, the application goes to "HOME" controller and "Index" action.

To fix this,
2. Set Controller = "Employee"

Run the application again. Notice that, all the employees are listed on the index view. We can also create a new employee, edit an empoyee, view their full details and delete an employee as well. However, there are few issues, with each of the views, which we will address in our upcoming videos.

Text version of the video

Slides

All ASP .NET MVC Text Articles

All ASP .NET MVC Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic
Рекомендации по теме
Комментарии
Автор

I really liked that you showed us the entity framework only after explaining how to do things without it. It's the best way to learn :) Thank you for your hard work!

ACLAproductions
Автор

Hi Ipsita, thank you very much taking time to answer this question. As, I am receiving lot of questions everyday from our youtube users, I am finding it extremely difficult to answer all the questions in time. With your help I am confident, we will be able to answer most questions in time. Appreciate your time and effort. God bless you.

Csharp-video-tutorialsBlogspot
Автор

You have the best tutorial even after seven year. All the other newer videos are not helpful. Thank you for making this video.

umeshverma
Автор

You make the best MVC Tutorials, thank you and greetings from Austria.

KnappStephan
Автор

Thank you for sharing your valuable knowledge with us ! Thanks a lot !

DineshKudale
Автор

That was exactly what I was looking for. simply awesome

awaisahmadsiddiqi
Автор

For those finding it difficult, here is what I did to get it working. I was using VS 2015 community edition, so first I installed SQL Express 2014. Then I created the table mentioned in the Tutorial. When I could not root cause my issue continue this tutorial from a backup i had taken soon after Chapter 6.

Thank you Venkat, really love your tutorials. (^_^)

ganeshkamath
Автор

Very nice tutorial! easy to understand and very helpful. Venkat, you are so awesome!

burn
Автор

Hi venkat u doing great job, I'm learning MVC through ur videos.Nice explination.

keerthikumarb.v
Автор

This video is useful for me,
Thanks and Regards.

trongbien
Автор

hello sir, thank you for tutorials, i am using vs 2012 when i add "ado.net entity data model " visual studio giving security warning that "running this text template can potentially harm your but after click on ok it generated .edmx file but is is different from the file which is generated in the

what to do....???

MohitSharma-urpl
Автор

your voice make me remember Life Of Pi.. LOL..
i mean, its good.. Thanks...

asendud
Автор

your tutorial are so useful and effective full of knowledge and i am so thankful to be able to learn. but can you please take a pause n take a breath and continue speaking without holding ur breath.

Staytrue
Автор

Can you please help in knowing, how we are having department in a form of dropdownlist?

vaibhavnag
Автор

Hi Sergei, I have never used toad as the client tool for sql server. I have always been using SSMS. Sorry, couldn't be of much help in this case.

Csharp-video-tutorialsBlogspot
Автор

I Appreciate Your Work Sir...Thank You For your videos they Are So Much Informative..
Can you Please Upload a video Which will explain
how to Insert update delete in MVC "without using entity framework" .
Thanks In Advance

ruchawarhekar
Автор

sir,
i am great fan of your videos, please start a video setup for wcf extensively as it is need of every organisation.hope you will start wcf after finishing mvc
regards,
rohit

mohitraina
Автор

Hello Venkat Sir, My question is when adding controller why we use Employee(MVCDemo.Models) why not Department(MVCDemo.Models) in Model Class

mayursingh
Автор

sir i have three cascading dropdownlist of country, state, city
how to take value in the dropdownlist from gridview in editmode?

prerakdesai
Автор

sure, we will discuss this in our upcoming videos.If you want to receive email alerts, when new videos are uploaded, please feel free to subscribe to my youtube channel. May I ask you for a favour. I want these tutorials to be helpful for as many people as possible. Please free to share the link with your friends and family who you think would also benefit from them. Good Luck.

Csharp-video-tutorialsBlogspot