Asp .Net MVC Full CRUD Operation Using Entity Framework DB First | CRUD Operations in MVC

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to my channel today we are going to start new series of mvc examples this is the first example in mvc in today's session we are going to discuss on crowd operations in mvc with entity framework by using db first approach for this we are going to use the technologies like visual studio 2019 and sql server 2012 if you want you can use visual studio 2013 and above versions you can use it and as sql server you can use any sql server it will support first we will create database then we will go to visual studio i am going to use microsoft sql server 2012 in this demo so i am going to use windows authentication if required you can use sql server authentication also i am selecting windows authentication before continuing with this session i will request you all please subscribe to my channel and click on bell icon for notification alerts here you have to select your server name and database instance click on connect it's connected to my database server so i expand the databases so we are going to create one new database right click on the databases new database here we have to provide the database name code with entity framework here you can select the path where you want to store your database i'm selecting d drive and sql data click on ok click on ok it's creating your database so our database is created here expand the database expand the tables here we will create one new table right click on the tables click on new table here we have to provide the name here we have to provide the column names giving us id it's integer it will not allow nulls and it should be primary key and i want to set this identity as 1 so that we now need to insert the id values into this column here you have to expand the identity specification and click on the identity if you are new to sql server you can follow my channel and there is a playlist called sql server tutorial you can use the tutorial here we selected identity as one and it will be incremented by one then here we have to provide the employee code it's integer to not allow nulls and employee name i'm giving us 100 characters and it's mandatory then we have to provide the designation this is also give it us 50 characters then finally we need salary i'm using as integer designation only i'm putting as mandate not mandatory designation column only this is also mandatory so now we created one table with all the mandatory fields now we have to save this table right click here save table and here you have to provide the table name i'm giving us employee master click on ok so our table is saved refresh on tables so our table has been created here for this demo we are going to use visual studio 2019 click on create new project select asp.net web application here click on next here we have to provide the project name so i provided the project name here here you can select the location where you want to store your project i'm selecting on documents we see so here i want to store my project and if you want to place your solution in the same directory you can check this otherwise you can uncheck this and you can select the latest framework which you have i'm selecting 4.7.2 click on create so that it will create our project here click on mvc we no need of https uncheck this click on create so our project is creating here our project is created now go to solution explorer now we have to add our database model to our project right click on the models click on add here we are going to add edward.net entity data model click on this here we have to provide our model name i am giving as employee model click on ok here i am selecting entity framework designer click on next here we have to provide the database connection here we have to click on new connection here we have to provide the sql server database name for that right click on our sql server database server so double click here copy this server name and sql server instance name paste it here and we are going to use windows authentication so that we are using windows authentication or else you can select the sql server authentication if you are using click on windows authentication here our database basis will be displayed click on crowd with ef this is the database which we created click on test connection our connection is succeeded there is any error you can see here click on ok so this is our entity name which will be saved in the web.config file click on next here all our database objects will be displayed expand the tables here we have to select employee master this is our model name click on finish so now that employee model is added to our project you can go to models this is our empire model and in this empty master table is added here this is our employee master class all the columns are mapped to the project now we have to add the controller right click on the controllers add controller here we are going to select with the controllers with the views using entity framework if you select this option it will create all the necessary options related to current operations like create read update and delete options we now need to create manually click on add here we have to select the database model that is employee master in our case here we have to select the database context so by default user layout will be taken from the shared folder so if you are not selecting any specific one by default layout will be selected here if you want to select any specific layout you can select it here here we have to provide the controller name giving us employee controller click on add now it's installing required nougat packages from the internet and by using scaffolding mechanism it is creating our views now our employee controller has been created here also our view is also created here open the employee controller here all the actions has been created this is the action where it will display employee list and this will be displayed based on the id employee id we can access only single employee details so whenever we want to create we will use this action and this is the action where we want to use it for create new employee and this will be used for edit the employee and this will be used to save the data while editing and finally here there is a delete function where it will be loaded based on the id and here we are deleting the record based on the id also it is generated all the views by using scaffolding mechanism if you open the create it's generated the view for create employee you'll run the application now so this is our default index we will try to add employee master here so that we don't need to go again and again manually to enter these details so if we provide hyperlink here from there we can access for that we have to open the shared folder and layout here we will add hyperlink for our employee master i am going to add one list item so i need one action link here we have to provide the link text i want to make it as employee master and then i have to provide the action name here at least index and finally i want to provide controller name that is employee save it now go to browser refresh here so our employee master is created here click on this just came to index click on create new i will provide one employee code here here i am providing name of the employee and designation and salary i'm making here create so its record is created i am going to create one more record here we have to provide the designation click on create our records is created if you want to edit click on edit so here i want to make it as some changes click on save it's saved if you want to click on details check the details if you want to delete this record you can click delete it will ask you for the confirmation or you should want to delete this if you click delete it will be deleted here so we will add some bootstrap styles to this form first i'll go to create employee and i want to change the button style here instead of default i want to make it as primary click on create new so our button color has been changed now now i want to make it for delete also so here i want to make it as delete employee only here we will change the button style danger and details also i'll change it i'll remove this this is employee details and also edit edit employee so i'll remove this for delete also delete you can change like this based on our requirement i can modify these things here also i will change it create employee so finally index also i will make some changes for this create new also we will create a button for that create one new class here btn btn primary so that new class will be added to this action link so i'll copy this thing for table also i'll give you table handler and table responsive i'm adding all bootstrap classes so based on your requirement you can add it for this edit details and delete also i'll add the buttons here okay this is primary and i don't want this here also i'll add one class for this btn success and i don't want this here also i'll add one class then you just edit completed details here also we can provide this delete how to provide danger then we have provided everything we will refresh this click on employ master now so our buttons are added here so here also it's added click on edit it's editing so edit template we have to change the button style make it as primary so refresh here so it's saved some details edit save we will add one more employee create so all the datas are saving into our database we can check it here our database is here we can check our records from our employee master table so all the records are inserting here we will try to delete one record delete deleted now now we will update one record so instead of the worker ready and making us the worker save it it's updated so we will give the edit here instead of say we will modify us update so that it will give the meaningful name here make it as update reload the page so it's working fine so all our crud operations working fine as we expected that's it for today if you like this video please like and subscribe to my channel thanks for watching you
Info
Channel: CodeWithGopi
Views: 80,145
Rating: undefined out of 5
Keywords: ASP.Net MVC 5 Database First with Entity Framework 6, Asp net Mvc Full CRUD Operation Using Entity Framework DB First, CRUD Operations using Entity Framework Database-first Approach In ASP.Net MVC, Crud operations, Crud operations in mvc, EntityFramework Db First approach in .NET 5.0 MVC with CRUD operations, Mvc db first approach, asp .net core mvc crud using entity framework, codewithgopi, crud, crud in mvc, crud operations, entity framework, entity framework core, mvc, .net core, c#
Id: OLBmtRFFwcQ
Channel Id: undefined
Length: 18min 49sec (1129 seconds)
Published: Wed Jul 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.