Тёмный

Part 6- ASP.NET MVC Database Connection Using Entity Framework | Connect to SQL Server database 

Technotips Ashish
Подписаться 30 тыс.
Просмотров 185 тыс.
50% 1

Hello ,if you want to make the database connection in asp.net mvc then follow the steps as I have done in video. Its very easy to connect a SQL server database within a few minutes in asp.net mvc. This is part 6 of the video series.
CONTACT US: technotipstutorial@gmail.com
SOCIAL :
Like TechnoTips official Page : / technotipstutorial
Subscribe : / aapkanigam
Follow us on Twitter : @technotipsMVC
VISIT OUR BLOG:
technotipstutorial.blogspot.com
INTRODUCTION :
Here you just need to follow the DATABASE FIRST Approach and using entity framework we can generate the model .All thing is automated as the entity framework helps to generate the model dynamically.Later we are supposed to use that model in order to manipulate data in Asp.net MVC .
I strongly suggest you to watch first five videos in order to consolidate your knowledge .
Watch MODEL VIEW AND CONTROLLER here
1. MODEL : Part 4- • Part 4- MODEL Binding ...
2. VIEW :Part 3- • Part 3- VIEW in ASP.NE...
3. CONTROLLER :Part 2- • Part 2- CONTROLLER in ...
TAGS :
how to create a - website
asp. net mvc
asp.net mvc interview questions
asp .net mvc tutorial
asp. net mvc 4
asp.net mvc 5 tutorial
asp net mvc developer
asp net mvc continuous integration
asp net mvc hosting
model view controller
jquery-ajax
$ ajax jquery
jquery ajax tutorial
viewbag
$controller
$model
razor view engine
$how to get rich

Наука

Опубликовано:

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 149   
@aapkanigam
@aapkanigam 6 лет назад
Click on thumbs up🖒 button if you like this video. 👉Subscribe our channel for real time MVC videos. And don't forget to 👉share this😁 Thanks💖
@amanjutt1591
@amanjutt1591 6 лет назад
hello sir I am following you you are doing well I have a little confusion can you help me?
@itsumokokoro5166
@itsumokokoro5166 7 лет назад
The test connection alert sound 3:35 , shocked me.
@aapkanigam
@aapkanigam 7 лет назад
+Iicir Yves Exiomo I was also shocked while making this video
@49NICOW
@49NICOW 6 лет назад
I think i'm dead too
@ronjones1587
@ronjones1587 5 лет назад
my hair stood up that time
@LetCode96666
@LetCode96666 5 лет назад
I just shit myself lol XD
@richievrutaal6152
@richievrutaal6152 5 лет назад
Thank you, this example worked for me.
@kirankumari-nz8lr
@kirankumari-nz8lr 7 лет назад
Thanks it helped me a lot. Loved you series.
@paragkotekar1763
@paragkotekar1763 6 лет назад
Nice and Detailed
@mattgrannen2
@mattgrannen2 Год назад
Thank you Ashish: You saved me a lot of time
@sohailakbar7577
@sohailakbar7577 3 года назад
Nice video. Easy to understand.
@trr5088
@trr5088 7 лет назад
Ashish, your name indicates a blessing and your help has indeed been that for me. On to number 7
@aapkanigam
@aapkanigam 7 лет назад
+TR Rooks keep it up !
@LuigiZuniga
@LuigiZuniga 7 лет назад
Thanks for your Videos!!!
@aapkanigam
@aapkanigam 7 лет назад
+Luis Alberto Pino Zuñiga keep learning and sharing
@hamzahahmed8657
@hamzahahmed8657 3 года назад
Thank you, bro
@shankarguru1309
@shankarguru1309 4 года назад
Awesome tutorial for beginners..!!
@aapkanigam
@aapkanigam 4 года назад
Thanks 😊 keep learning and sharing 🙏
@ayoforyou448
@ayoforyou448 4 года назад
many thak's mate
@markusmulholland
@markusmulholland 5 лет назад
Very easy to follow and understand. Thank you sir
@narendarsingh4672
@narendarsingh4672 5 лет назад
great
@navzme
@navzme 6 лет назад
Thanks for awesome video
@aapkanigam
@aapkanigam 6 лет назад
Thanks ..keep learning and sharing
@saivigneshwaran150
@saivigneshwaran150 4 года назад
Thank You
@Infinitesap
@Infinitesap 6 лет назад
Awsome quality of teaching! Thanks very much :)
@aapkanigam
@aapkanigam 6 лет назад
Thanks ..keep learning and sharing
@DanGerouszaPoisonous
@DanGerouszaPoisonous 4 года назад
TY 2k times !!!
@nguyenhongduong8688
@nguyenhongduong8688 6 лет назад
Thank you so much, This video is very important with me
@visaboxofficial
@visaboxofficial 6 лет назад
Excatly, This is what i wanted.... An other Guy on RU-vid has Also such Wonderful Videos To go On with MVC, but he missed this step, which took my 4 days, and forced me to switch to some other tutorials, which ultimately are your's Now. Stay Blessed !
@aapkanigam
@aapkanigam 6 лет назад
+Art Is LIFE is Art Thanks keep learning and sharing
@n.hartmann5534
@n.hartmann5534 5 лет назад
Im guessing the other guy is KudVenkat:)
@bijoy_7168
@bijoy_7168 5 лет назад
It is helped me a lot
@aapkanigam
@aapkanigam 5 лет назад
Keep learning and sharing thanks
@daviddonadze221
@daviddonadze221 6 лет назад
Thank u so much for this detailed Video. u are the best!!!!!!
@aapkanigam
@aapkanigam 6 лет назад
+David Donadze Thanks ..keep learning and sharing
@lifet4800
@lifet4800 7 лет назад
hii ashish,is code first approach or entity framework is better..?
@fariatam9153
@fariatam9153 7 лет назад
hello,nice videos :) but im facing difficulties while creating entity model from database which is on 2.40.i dont have the option "Generate from database".I used visual studio 2017 as i didn't find 2013 version anywhere.how to solve this problem?
@someone418
@someone418 7 лет назад
thanks for reply. C# Function.
@aapkanigam
@aapkanigam 7 лет назад
+Priyanka Gupta Yes you can create many method which is returning something. Like string , int , list, class etc .. suppose you want to create add funtion then use public int Sum (int i,int j){ Int c= i+j; return c; } Call this function in any other class .. Example - int result= Sum (5,7);
@bhaskarkholiya8125
@bhaskarkholiya8125 6 лет назад
Hi, i can't see Generating from database option in ADO.NET Entity Data Model. Please help i am using ms sql server 2008 and visual studio 2015
@vishnuc4661
@vishnuc4661 Год назад
Hi, ashish actually in mac os sql server studio management is not avilable ,can u suggest any free alternatives
@someone418
@someone418 7 лет назад
nice tutorial. if we have to create many function then how will we call this function n where.
@aapkanigam
@aapkanigam 7 лет назад
+Priyanka Gupta are you talking jquery or c# function
@kiennhanmeffu2678
@kiennhanmeffu2678 3 года назад
Can you explain me actually what happening here from 8.19
@Mulllll
@Mulllll 6 лет назад
hey ashish. Your tutorials are great and helps me a lot. even i do everything like you i get a error: "System.NullReferenceException. the object reference didnt define a object instance" something is wrong with the instancing of employee oder employeeVM. I am working with a local sql db but i think that is not the problem. Any Ideas? i am frustrating so much
@aapkanigam
@aapkanigam 6 лет назад
Sorry for delay in response, You can get the code from the link given in description. If you find any difficulty the please free to ask ,, thanks
@Anilkumar-pi6gf
@Anilkumar-pi6gf 7 лет назад
Thanks! Your videos are very helpful. It would be great if you provide code for this series.
@bobtaylor1577
@bobtaylor1577 5 лет назад
I jumped from tutorial 4 to tutorial 6 because of your sql !!!!!!!
@ramanjulureddy2458
@ramanjulureddy2458 4 года назад
Do you have any Git repository for this...
@robelbeyene84
@robelbeyene84 7 лет назад
Thanks for the wonderful tutorials. I got this error though: + $exception {"Object reference not set to an instance of an object."} System.NullReferenceException I'm using VS2017. How do I solve this issue?
@aapkanigam
@aapkanigam 7 лет назад
+Robel Beyene this error comes when null value coming in your variable and you are using it some where . May be you are not getting data in your ViewBag. And you are using it on view page and doing iteration on it. Also make sure to check correct key and value pair .
@air32k
@air32k 7 лет назад
Hi! Do you have a tutorial for creating this database and inserting data into it on SQL Server management tool? This should come helpful for continue this tutorial without getting help from other videos from YT except this tutorial.
@aapkanigam
@aapkanigam 7 лет назад
+Spectral501 part 26 might help you ..
@air32k
@air32k 7 лет назад
Thanks
@erfanmehrvash
@erfanmehrvash 7 лет назад
Hi Sir, Is it possible, share the code? Because I have some error like The name 'model' does not exist
@ElPeppito
@ElPeppito 3 года назад
3:34 jesus fucking christ i almost had an heart attack
@reyneermoisesmoralesleon6062
@reyneermoisesmoralesleon6062 5 лет назад
i get this error: Object reference not set to an instance of an object.
@ewomaanthony3655
@ewomaanthony3655 7 лет назад
Am having this error Error CS0029 Cannot implicitly convert type 'MVCTutorial.Models.tblEmployee' to 'MVCTutorial.Models.Employee'
@jayendraadam4133
@jayendraadam4133 6 лет назад
may i know sql datatype which is used here for Employee_Id
@aapkanigam
@aapkanigam 6 лет назад
+Jayant Adam its an integer
@mohanmani4245
@mohanmani4245 Год назад
HOW TO GET MULTIPLE DATA IN DB CONECTIION
@srijanghosh4367
@srijanghosh4367 6 лет назад
hello sir...my sql server database table could not show in my model.tt. what can i do ???
@aapkanigam
@aapkanigam 6 лет назад
+Srijan Ghosh watch part 26 , you will get some idea
@CommanDoHighTech
@CommanDoHighTech 5 лет назад
for every one how have Exception in (x=>x.ID) you make the relationship in a wrong way you will make relation between Department Table and Employee the foregin key will be in the table employee CREATE TABLE [dbo].[Employee] ( [ID] INT IDENTITY (1, 1) NOT NULL, [name] NVARCHAR (MAX) NULL, [Dep] INT NULL, [addr] NVARCHAR (20) NULL, PRIMARY KEY CLUSTERED ([ID] ASC), FOREIGN KEY ([Dep]) REFERENCES [dbo].[Department] ([DepID]) ); or in the sql query you will make it departmentID int references Depatment(DepID)
@logingoogletesttest6690
@logingoogletesttest6690 5 лет назад
how to login with google and fb in mvc and save data in db ?
@assiadehmani5000
@assiadehmani5000 7 лет назад
thanks for this video i have a problem in the(x=>x.EmployeeId == 1) in index page , can you help me ?
@aapkanigam
@aapkanigam 7 лет назад
+Assia DEHMANI yes please.
@assiadehmani5000
@assiadehmani5000 7 лет назад
error in this line Employee employee = db.Employees.SingleOrDefault(x => x.ID == 1); exactly in ID Any suggestions please ?
@aapkanigam
@aapkanigam 7 лет назад
+Assia DEHMANI Its seems to be correct.. but what error are you getting. Try to use var employee = db.Employees.SingleOrDefault (x=>x.ID==1);
@ounly5094
@ounly5094 5 лет назад
Hello sir! Can you help to create a video for search data using textbox?
@aapkanigam
@aapkanigam 5 лет назад
Please watch part 37. Thanks
@dulajudayanga4050
@dulajudayanga4050 7 лет назад
@Model CREATE_MVC2 hello sir when I try to add like this in my view Index.cshtml , I can not see any intellisense plz tell me how do add my model clz to view index
@aapkanigam
@aapkanigam 7 лет назад
+Dulaj Udayanga it should be @model not @Model
@dulajudayanga4050
@dulajudayanga4050 7 лет назад
thank you so much great answer , I have watch so many videos in RU-vid to learn MVC but not anyone to teach like you , thank you so much , Have a Great life Sir
@aapkanigam
@aapkanigam 7 лет назад
+Dulaj Udayanga thanks.. keep learning and sharing
@krishnaparab9747
@krishnaparab9747 7 лет назад
How to add update & delete Events in Calendar in MVC ?
@sanaullah-my2tm
@sanaullah-my2tm 6 лет назад
sir i am getting error in view when i want to write @model mvctutoral.models.EmplyeeViewModel then it is showing error the type name models does not not exst in system.web.mvc please solve my problem
@aapkanigam
@aapkanigam 6 лет назад
Name is case sensitive
@tejaswininanaware
@tejaswininanaware 6 лет назад
Is the TestController an empty controller?
@aapkanigam
@aapkanigam 6 лет назад
There is only one method which will return a View
@mohammadfasih7752
@mohammadfasih7752 7 лет назад
what we should code if we want to display all the emplyees insted of one???
@aapkanigam
@aapkanigam 7 лет назад
+Faizan Raza watch part 16
@mohammadfasih7752
@mohammadfasih7752 7 лет назад
ok!!
@yoskar18xd
@yoskar18xd 5 лет назад
im having problems adapting SQL db to the project, i've missed the part where you explained that, pls help!
@aapkanigam
@aapkanigam 5 лет назад
Please watch 26 for updating entity after any modification to table or db
@yoskar18xd
@yoskar18xd 5 лет назад
@@aapkanigam well sorry, I just found out sql is not available, so I don't even have the DB install on visual studio, any alternative?...
@yoskar18xd
@yoskar18xd 5 лет назад
In Mac I Meant!
@SanjayKumar-hc6iu
@SanjayKumar-hc6iu 7 лет назад
Hi Ashish...I am Unable to create relationship in "MVTutorial.edmx" file.Could you please guide here how to Create Relationship between Department and Employee Table here????Appreciate you Kind attention...
@aapkanigam
@aapkanigam 7 лет назад
+Sanjay Kumar part 26 will help you
@SanjayKumar-hc6iu
@SanjayKumar-hc6iu 7 лет назад
Many Thanks...Let me Complete Upto Lab25..
@sunnyjagtap1171
@sunnyjagtap1171 6 лет назад
sir you dont have video on database connection without entity framework...Ado.net??
@aapkanigam
@aapkanigam 6 лет назад
Nope..
@learnbydibya
@learnbydibya 5 лет назад
Sir, can we use MVC with ADO.NET connection?
@sandoval3265
@sandoval3265 5 лет назад
Yes, you also can use LINQ to SQL.
@diogoteixeira9863
@diogoteixeira9863 5 лет назад
How do I do if I want to output all the data from the database?
@aapkanigam
@aapkanigam 4 года назад
Db.TableName.ToList ()
@trr5088
@trr5088 7 лет назад
Ashish, I am starting Part 6 - Asp.net MVC Database. Should this be a new project? Before we have always built on previous lesson.
@aapkanigam
@aapkanigam 7 лет назад
+TR Rooks (TRR) no need to create new project .you can work on same controller .just create one more method and start . Technotips now on fb .you can visit fb.com/technotipstutorial .please share videos among your friends and help them too.thanks
@iftikharhussain1823
@iftikharhussain1823 4 года назад
how to create forign key between employee and department tables
@aapkanigam
@aapkanigam 4 года назад
Part 26 can help you
@crizalyncauilan8094
@crizalyncauilan8094 6 лет назад
where is the database you use in video?
@aapkanigam
@aapkanigam 6 лет назад
part 26 will help you
@aliridhohabsyi1242
@aliridhohabsyi1242 6 лет назад
Aisihis i got a problem with "employeeVM.EmployeeId = employee.EmployeeId;" because "An exception of type 'System.NullReferenceException' occurred in Technotips.dll but was not handled in user code." What should i do ??
@aapkanigam
@aapkanigam 6 лет назад
+Ali Ridho Habsyi check for null value in model before assigning any property. Ex if (model!=null){// assign values }
@Mulllll
@Mulllll 6 лет назад
got the same problem. the delet of "if (Model!=null)" gives the same error
@aapkanigam
@aapkanigam 6 лет назад
+Michali Alex dont delete that .. are you sure you getting data from database? If you are inserting data and you id is primary key not nullable then dont assign any value to it.
@aapkanigam
@aapkanigam 6 лет назад
+Michali Alex dont delete that .. are you sure you getting data from database? If you are inserting data and you id is primary key not nullable then dont assign any value to it.
@Mulllll
@Mulllll 6 лет назад
hey ashish. thanks for answering so fast. i will subscribe and share your videos. i am not sure if i get data from database. in the first 4 videos i got data from database. but since i use the entity framework i get the nullreference exception. even if i check if model is not null. could it be that there is no conneciton to my database? but everything looks like in your video. damn since 4 hours i try to solve htis problem.
@meghamisra5622
@meghamisra5622 7 лет назад
I want to create a report using join query. in SQL server I can use join query and get the report but I want the do same thing in MVC5 can you please tell me how to generate the report using join query in MVC and also tell me what is Migration in MVC I saw many posts saying that if you update table or database u need to use migration. If there is data in existing table I may loose them if I use Migration right.
@aapkanigam
@aapkanigam 7 лет назад
+Megha Misra Use linq query to implement join in mvc
@meghamisra5622
@meghamisra5622 7 лет назад
ok Thank you for your quick reply. Do you have any video of linq?
@aapkanigam
@aapkanigam 7 лет назад
+Megha Misra No right now I don't have..you search on google on linq join queries
@meghamisra5622
@meghamisra5622 7 лет назад
ok Thank you so much for your help
@aapkanigam
@aapkanigam 7 лет назад
+Megha Misra Welcome..keep learning and sharing
@Part-II
@Part-II 5 лет назад
Sonic BOOM at 3:35 :E
@meghamisra5622
@meghamisra5622 7 лет назад
error in this line Employee employee = db.Employees.SingleOrDefault(x => x.ID == 1); An exception of type 'System.Data.Entity.Core.MetadataException' occurred in EntityFramework.dll but was not handled in user code Additional information: Schema specified is not valid. Errors: The relationship 'Test_TrainingModel.FK_Documents_Employees' was not
@aapkanigam
@aapkanigam 7 лет назад
+Megha Misra I think problem is in your table relationship in db . Make sure you have properly updated you edmx file with latest changes in your db table . Part 26 and 25 will help you to do this.
@faizakhan6724
@faizakhan6724 7 лет назад
Sir same error in my code... I have done it two times but same error... :( Any suggestions?
@nguyentamtoan
@nguyentamtoan 6 лет назад
why do you have to create class EmployeeViewModel? no EmployeeViewModel, the application is Ok.
@aapkanigam
@aapkanigam 6 лет назад
No, it will create lots of problem .. your view will be tightly coupled with entity classes. If you refresh your Entity framework after having any change to db schema, your view will be impacted
@ender2999
@ender2999 5 лет назад
Jump scare at 3:35
@aapkanigam
@aapkanigam 5 лет назад
Loz😅
@faizakhan6724
@faizakhan6724 7 лет назад
It's giving me the following error: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'WebApplication1.Controllers.EmployeeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
@aapkanigam
@aapkanigam 7 лет назад
+Faiza khan in you db table the id column can not accept null value. If id column having primary key then also make it auto incremental. When new entry is save the id will automatically increased. For making auto increment watch part 26 . It will also help you to create new table with relationship with other.
@faizakhan6724
@faizakhan6724 7 лет назад
oka Sir will try it again... Thanks for replying
@Abedi000
@Abedi000 7 лет назад
Very helpful video - I suggest try to drink some water beforehand so we don't hear your mouth while talking
@aapkanigam
@aapkanigam 7 лет назад
+Christopher thanks for ur suggestion .. the mic was so closure to my mouth .. and did not have idea about quality ..but no worry .. after part 10 you will find good experience
@suerbarsylmaz9792
@suerbarsylmaz9792 7 лет назад
arkadaşlar bu linkten en güncel haliyle okullarda gösterilen veri tabanı uygulamasının
@aapkanigam
@aapkanigam 7 лет назад
+Suer Barış Yılmaz can you please write this in English
@csabasomogyi6780
@csabasomogyi6780 6 лет назад
How can i create database?
@aapkanigam
@aapkanigam 6 лет назад
+Csaba Somogyi watch part 26
@csabasomogyi6780
@csabasomogyi6780 6 лет назад
I dowloaded the sql server managment studio but i can't know how can i connect to database.
@aapkanigam
@aapkanigam 6 лет назад
+Csaba Somogyi watch part 6
@jenasusil6
@jenasusil6 6 лет назад
Hello sir 1st of all Thank you very much for your beautiful videos..Sir can you please help me to solve this below error. Even after i have changed my control name in route config file i am getting the same error. Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: / Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36290
@aapkanigam
@aapkanigam 6 лет назад
+Susil Jena please check the controller and method name ..and then route. config file . This error comes when either the requested file is missing or incorrect method or controller name being mentioned.
@jenasusil6
@jenasusil6 6 лет назад
Technotips - Ashish sir i have updated my controller name and action method name in routeconfig.cs file.but still i am getting same error.
@aapkanigam
@aapkanigam 6 лет назад
+Susil Jena There might be problem with your route config file . If you are using attribute routing the Part 38 may be helpful for you to set correct route value .
@bobtaylor1577
@bobtaylor1577 5 лет назад
i do not have any server names. Dude you are skipping alot of stuff
@aapkanigam
@aapkanigam 5 лет назад
Nope
@dharmenderkapil
@dharmenderkapil 4 года назад
I didn't Understand the Part 5 of mvc it was not so cool Sorry!!!! :( :(
@hamedkadkhodaie7715
@hamedkadkhodaie7715 7 лет назад
No ! No ! No ! why are you calling the Database in controller ? You are ruining your MVC Pattern, it's DB
@aapkanigam
@aapkanigam 7 лет назад
+Hamed kadkhodaie Hey dear .. I have not explained repository pattern yet .. there will call database from data access layer-> business -> controller -> view
@aapkanigam
@aapkanigam 7 лет назад
+Hamed kadkhodaie MVC does not have to do with the architecture you have provided . If I dont use model ,still I can render data to view. YOU can call database directly from controller without having any issue.
@Anilkumar-pi6gf
@Anilkumar-pi6gf 7 лет назад
Hamed kadkhodaie Yes you can call the database from controller. At Microsoft official site you will get several example of controller calling database .
Далее
PORTAL SPAMMER🤬🤬🤬| Doge Gaming
00:19
Просмотров 1 млн
I've been using Redis wrong this whole time...
20:53
Просмотров 347 тыс.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Просмотров 187 тыс.
Why The Windows Phone Failed
24:08
Просмотров 232 тыс.
DbContext in entity framework core
5:19
Просмотров 227 тыс.