Entity FrameWork C# | How to insert Data in Database in C# Visual Studio 2022

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my Channel today in this video tutorial we are going to learn about the Entity framework and C shop we will be doing crowd operations with Entity framework uh into our database so in this tutorial we will learn about inserting data with Entity framework so I'll close this this as well now if I a per Entity framework first we will go to new get package manager here and here we will search for Entity Framework six and we will install this as I have already installed this you can see this blue Tech you have to click on this you have to click this and then this install and it will automatically install now if I show you my installed uh packages so you can see Entity framework here so in this way you can install it now if I go here so this is a our form so I will drag in some controls to this so I'll drag in text box I'll drag it then I will drag it uh label so this is label and then I will drag in button and I'll drag this button as well now I'll drag it to this side and to this as well and now I'll click on this and unused SPD name and now I'll expand it a bit and now I'll select these both both of them and now Ctrl drag them to be to duplicate them and now I'll control drag them again from now I'll drag this button here now I'll change the text size of this as well so I'll come here and I'll select fonts I'll change this to uh 10. and bold and okay now it is looking good now I'll change the text on this button so first I will change the name of this button so I'll change the name to insert I'll make this small insert vtn and now I'll go and change the text as well so I'll go down and here I will change this insert now the text is chant now I'll double click on this to create its click event um but uh before writing code here we have to go here into our project and we will add in a new item so I'll just need to add in a new item now we have to come to this data and select this one edu.net entity and I'll make this uh model and now I'll click add now EF designer from database next and here we will select new connection and here I can put a dot or I can put a alternatively I can come here disconnect this and a Skillman studio and I will copy this this is my server name and connect and now I created by the way I've created the student table and SD table which has student ID student name and student fname and student City so I have inserted this one record now we will insert other records into it so for that I will come here and I'll Ctrl V it here now we have this so I'll come here to this uh student DB we have this student table in the student DB and I'll click ok now I'll click next and now from here I'll select the table in which we want to insert the data so I'll click this and I'll finish this so now you can see it has created this is the table class which is our table in the database this one as you can see here is the table and it has all also created this model.edmx which we will use uh later and this now I'll come to this and go to this button click event and now here we will at the top we will create an object for our HD table so SD table model is the model equal to new SE table and now I'll put this in semicolon now I'll use student DB entities 3D student DB equals new student EB entities and now I'll put semicolon now uh we will use a SD model Dot as we have this stdid but as we can see here then I have kept this uh STD IDE Primary Care not to increment it so we do not need to supply this so I'll come here back and we will use STD name and we will use that uh for that text box one dot text and I'll put semicolon and then stdmodel Dot set this PDF name then text box two Dot and text semicolon and similarly STD model dot stdc City equals to text box three dot text and I'll put semicolon now so now here we will use student DB Dot is the tables dot add and we will pass in the uh SD model and now we will put semicolon here and now uh student DB Dot save changes and now I'll put semicolon here now we are good to go so let's run this application and let's enter and you record and let's check so now the application is running so if I insert here uh m i k and here uh goal and CTS uh Karachi and now if I submit now we do not have any uh com message box here so we will uh refresh this or select the table again or we will execute the query here so tables and this is the tables this D table and now if I select top 1000 rows so you know you can see mik equal and Karachi is inserted now if I insert change this name to Han and this is to Islamabad and now if I answer this and now if I go and uh execute it again now you can see and that record is also inserted so in this way we can use our data with entity Paramore so I think that's all for today I hope you like the video if you like the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 6,160
Rating: undefined out of 5
Keywords: programming guru, Entity framework how to insert data in dataabase in c# visual studio code 2022, how to insert data in database using entityframework, entity framework, entity framework tutorial, how to insert records in database with entity framework c#, insert data in visual studio 2022 with entity framework, visual studio 2022, visual studio, sql server, sql server 2019, entity framework core, how to use entity framework in c#, entity framework example in c#
Id: 1HBMrDFZGOI
Channel Id: undefined
Length: 9min 25sec (565 seconds)
Published: Thu Nov 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.