Part 8 Data access in mvc using entity framework

  Рет қаралды 948,327

kudvenkat

kudvenkat

Күн бұрын

Пікірлер
@sheshendraguntamukkala3895
@sheshendraguntamukkala3895 10 жыл бұрын
I am new to MVC and my company gave me one project based on MVC with a description do or die, so i didn't find any solutions from last few days. But after watching some of these videos i am now clear that how to start that project. Really HATS OFF to you VENKAT SIR..
@vladvlad2289
@vladvlad2289 5 жыл бұрын
I was following someone else's tutorials to get this done, I've spent about 5 hours trying to wrap my head around it, then I came here and in 15 minutes I got it done! Awesome tutorials, thank you
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
Hello Vlad - Thank you very much. Means a lot. Reall glad you found our MVC course useful. I have organised all the ASP .NET MVC Course videos, slides and text articles in sequence on the following page. Hope you will find it handy. www.pragimtech.com/courses/asp-net-mvc-tutorial-for-beginners/ If you have time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Yes, it should as long as the same schema and metadata exists on the full-fledged SQL Server that you are switching over to. Thank you very much for taking time to give feedback. I am very glad you found these videos useful.
@rosw49
@rosw49 11 жыл бұрын
Your tutorials are some of the best I have seen. Thank you.
@tejas8437
@tejas8437 3 жыл бұрын
which other are rest of the best ?
@kaligasm1947
@kaligasm1947 7 жыл бұрын
Another great video. What struck me was that you were able to interrogate the database with writing any SQL! Presumably you can use the approach shown in this video to interrogate much more complex queries (or views) in SQL Server provided those queries have already been written in SQL Server first. I'm going to try this out.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
HI David, yes, with business objects we usually use ado.net. Business objects use ado.net to retrieve data from the database. We will discuss, using business objects in a later video session.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
We will discuss about editing, deleting, updating data in our upcoming videos.
@emmazh6474
@emmazh6474 11 жыл бұрын
Your tutorial full of details and clear, really being a great helper . Thanks U.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Can you make sure that you have an object in "homepages" collection property where Id is 1. You can very easily check this by debugging your application. Also, please make sure to check the underlying table has a rows where Id = 1. Hope this helps. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists. Please share the link with your friends.
@SydurRahman21
@SydurRahman21 8 жыл бұрын
Thank you venkat, I have complete part 8 without any error.... you are great!!!
@ajaychowdary5317
@ajaychowdary5317 8 жыл бұрын
Employee employee = employeecontext.Employees.Single(emp => emp.EmpId == Id); i got a error here. how to slove otherwise forword to the code to my mail daggubati.ajay9@gmail.com
@ubaidrehmanqureshi
@ubaidrehmanqureshi 8 жыл бұрын
bro how u made database?
@ajaychowdary5317
@ajaychowdary5317 8 жыл бұрын
+Ubaid Qureshi it's sloved bro
@ubaidrehmanqureshi
@ubaidrehmanqureshi 8 жыл бұрын
+Ajay Chowdary if u using visual studio 15 then we have SQL database options within that project. u used external database manager or the one which is inbuilt visual studio ?
@bablykiran9577
@bablykiran9577 3 жыл бұрын
@@ajaychowdary5317 If u got ur mistk thn plz tell ,I hav same prblm.
@DineshKudale
@DineshKudale 6 жыл бұрын
Thank you for sharing your valuable knowledge with us ! Very simple and nice video to understand ! Thanks a lot !
@evanflink7073
@evanflink7073 10 жыл бұрын
At 5:23 of the presentation, did you mean to say that you should manually type in a Connection String, similar to that shown at 3:27, in notepad? Because, unless I overlooked something, I did not get an automatic creation of that connection string when I created my EmployeeContext.cs file. I'm running VS 2013 Express. Otherwise, I find these tutorials very helpful.. Thanks very much!
@abhivaxs
@abhivaxs 11 жыл бұрын
you change my attitude towards .net technology .....you are awesome....i have realy respect for you becoz you share a good video and understanble thinks .......please donot stop to upload new videos ....thanks
@kenmtb
@kenmtb 10 жыл бұрын
Excellent video series!! Thank you very much for posting. If you are getting errors like "The underlying provider failed on Open", check the error's details to find the inner exception. There can be more info to pinpoint what is wrong. You may have login issues or problems in your connection string in the config file. Check your database service to see if a password is enabled. If so you need to provide it in the config string or remove the password in the service.
@RocckeFella
@RocckeFella 5 жыл бұрын
So If I have 100s of Model classes am I supposed to initialize them all in Application_start method?
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
They are pretty much the same. A class is a very general concept, where as entities are mapped to some objects that are usually saved to a database table. Example Employee, Student, Company etc. In my opinion there are the same.
@denizcalskan711
@denizcalskan711 11 жыл бұрын
i received a error when the program ran. it'S about "The underlying provider failed on Open." EntityExceptionwas unhandled by user code. its showing this code => Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id); can it be from connectionString ?
@antonykhomeriki2680
@antonykhomeriki2680 7 жыл бұрын
Same fom me . the solution sould be: 1) (In your sql server db) set column name "employeeId" to Primery key and (In your programm Models -> Employee.cs) add "[key]" (representing in using System.ComponentModel.DataAnnotations;) [Key] public int employeeId { get; set; } 2) Edit your connectionString: instead of server=localhost or server=. , insert there fully qualified server name: in my case it is "server=DESKTOP-301UN48\SQLEXPRESS;" you can see you connection name by right clicking in your connection (in sql server) choosing "properties" if it is not already shown at the right courner
@lbhatt
@lbhatt 7 жыл бұрын
Many thanks Anthony
@sumitbhardwaj2992
@sumitbhardwaj2992 7 жыл бұрын
Many Many thanx Mr. Antony Khomeriki finally i solve this problem after 8 days with your help please give me your contact link like facebook or other social networking site.
@karunkumar4245
@karunkumar4245 7 жыл бұрын
thank you Antony
@birendranathruidas6517
@birendranathruidas6517 6 жыл бұрын
Thank you, Antony. It worked :)
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
To retrieve all the records, get rid of the Single() method. employeeContext.Employees.ToList() should return the complete list of employees in tblEmployee table. Hope this answers your question.
@Algebrodadio
@Algebrodadio 9 жыл бұрын
Do I need to make a separate connection string for every database table that I will access? Shouldn't I be able to tell the EmployeeContext class which connection string to use if I already have one?
@aldoblack5982
@aldoblack5982 9 жыл бұрын
Aaron Wolbach I was thinking the same thing. I hope someone answers.
@aldoblack5982
@aldoblack5982 9 жыл бұрын
Aaron Wolbach I got it. You can create a new class with models, and on Employee Context you can call it DBSet youName { get; set; } I think so, I have not tested it.
@ImranAnsariM
@ImranAnsariM 11 жыл бұрын
Hi Guys people who are not able to move ahead with the database connection. Please note that when you install Entity Framework now from Nuget. It Downloads the Newest version which is EF 6.0.2. You need to do additional configuration changes to make it work, So i would prefer to suggest install from Nuget by Nuget Package manager condole and download EF 5.0 which is supported by this tuotrial. Steps:Go to Tools -> Library Package Manager->Package Manager Console and Type PM> Install-Package EntityFramework -Version 5.0.0 Hope this helps you all :)
@ImranAnsariM
@ImranAnsariM 11 жыл бұрын
Yasar Mahmood Coz you might not have data in the table
@dkapper01
@dkapper01 11 жыл бұрын
Cool thanks
@ImranAnsariM
@ImranAnsariM 11 жыл бұрын
nargeez backer Please you also help others by your knowledge :)
@QuyetNguyen-ie1jc
@QuyetNguyen-ie1jc 11 жыл бұрын
I got the error "The underlying provider failed on Open." in line: Employee employee = employeeContext.Employee.Single(emp => emp.Id == id); even I changed to EF5.0.0 Pls help me out.
@Anilgollapalli
@Anilgollapalli 10 жыл бұрын
Quyết Nguyễn im getting the same error if you solved it please tell me solution
@b0sStAB
@b0sStAB 9 жыл бұрын
Thanks for this tutorials man! God bless you!
@XxImBlessedxX
@XxImBlessedxX 8 жыл бұрын
You should have shown us how to create the database, I managed to get it working but it would have saved me a lot of time trying to figure out how to connect to the database -_-
@ubaidrehmanqureshi
@ubaidrehmanqureshi 8 жыл бұрын
bro having same issue. will u help me out
@brunothebeagleofficial
@brunothebeagleofficial 8 жыл бұрын
FinalXChapter i am getting the same error, did you find any solution
@lifet4800
@lifet4800 7 жыл бұрын
see asp.net tutorial for db
@jigneshvyas3105
@jigneshvyas3105 7 жыл бұрын
Go through his series on SQL server. And mind that he is doing this for free.
@brianblackie9434
@brianblackie9434 7 жыл бұрын
In case someone is watching this now.... Database script is here >>> csharp-video-tutorials.blogspot.co.nz/2013/05/part-10-working-with-multiple-tables-in.html
@vijay1015
@vijay1015 10 жыл бұрын
We have to define the key in code as following after making empid as primary key in Database: [Key] public int empId {get;set; } then this example works like charm.
@kamacac87
@kamacac87 10 жыл бұрын
Many thanks Vijay. I was wondering and searching here and there how it was working fine in the video BUT not in my example where the table had a primary key. thanks, it works like charm....
@Mrkandy422
@Mrkandy422 10 жыл бұрын
Thanks man! that worked.
@shaheerahmad7818
@shaheerahmad7818 7 жыл бұрын
And people are saying connection is wrong LOL
@abhisheksharma1896
@abhisheksharma1896 7 жыл бұрын
Key is not working in my case actually its not getting the "key" keyword ... plzzz help me out I'm using version 4
@mohitaggarwal1037
@mohitaggarwal1037 7 жыл бұрын
+Abhishek kumar Sharma Did you solve it..
@vanchalakhotia1368
@vanchalakhotia1368 11 жыл бұрын
Dear Sir , Excellent explanation .Really like your video as it is very easy to understand. You explain very well. vancha
@anuragpandey5952
@anuragpandey5952 11 жыл бұрын
sirji u r great u made Dotnet a very easy language you are sachin tendulkar in the field of programming thank you so much sir
@lakshmi.m4072
@lakshmi.m4072 9 жыл бұрын
Getting below error while running the app: The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe. connection string in the config file :
@SixStringflyboy
@SixStringflyboy 9 жыл бұрын
Love this tutorial series so far. One question: As someone who is experienced in other areas of .NET, I started with the MVC tutorial series. Where do we find the Sample database you use in this tutorial? Thanks! n122vu
@carminabernat
@carminabernat 9 жыл бұрын
+n122vu I was wondering the same thing.....
@saiavishkar2098
@saiavishkar2098 9 жыл бұрын
you need to create a sample database consisting of Employee table using SQL server or some other database systems
@SixStringflyboy
@SixStringflyboy 9 жыл бұрын
That's what I ended up doing. I paused the video when he showed each table and just created them based on that.
@Mattague
@Mattague 8 жыл бұрын
+n122vu For those of us lost even there, I've never done database before. How do I go about building my own sample database?
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Hi Rob, very sorry for not replying to your question in time. The problem is, I am getting too many questions and not finding time to reply to everyone on time. Hope you can help me, by answering some of the questions, for which you have answers. Coming to your question. Try this 1. Expand "References" folder from "Solution Explorer" 2. Delete the reference for "System.ComponentModel.DataAnnotations" Will be continued.....
@rajendranan4154
@rajendranan4154 7 жыл бұрын
Hi venkat, In employee model class if I not specify [Key] on top of the properties declaration getting exception after adding [Key] attribute working as expected.. could you please tell me what is the use of adding [key] attribute???
@b0sStAB
@b0sStAB 9 жыл бұрын
I am having this message -- An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: The underlying provider failed on Open. The problem points here: Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeID == id); -- Changed my connection string as suggested in the comments here but still unable to open database. All my connections are OK though. I have no idea where the problem is coming from.
@b0sStAB
@b0sStAB 9 жыл бұрын
b0sStAB I found the problem already. Followed this - stackoverflow.com/questions/24822076/sql-server-login-error-login-failed-for-user-nt-authority-system
@naveenk36
@naveenk36 9 жыл бұрын
b0sStAB No joy at all, spending lot of time but could not get pass through...
@andrewshults6445
@andrewshults6445 6 жыл бұрын
yeah I'm having the same problem. This is preventing me from even continuing the tutorial and its only lesson 8 -_-
@deepakchawla1112
@deepakchawla1112 8 жыл бұрын
I am Getting an exception"entitywasnothandledbyusercode" while runnning this code and message is "the underlying provider failed on open. " could you please advise me on this what can i do for getting output ? i done a same code as you have done in video...i am using visual studio 2012,sql sever management studio 2008,entity framework 6....may be this is not connected to database
@deepakchawla1112
@deepakchawla1112 8 жыл бұрын
Kindly Advise Sir
@MrZ1231986
@MrZ1231986 8 жыл бұрын
Check your settings in connectionString He use connectionString="server=." your server could be diffrent name like server=DESKTOP-O25GLU5\SQLEXPRESS
@nasimk3680
@nasimk3680 8 жыл бұрын
Thanks Bro. Finally I solved my problem by entering correct SERVER name (PC_Name\ServerName). THANKS.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Nope, users doesn't need to enter ID in the URL. When we click on the delete button the ID gets passed. This is discussed in the subsequent videos in the MVC tutorial. Hope you will find them useful.
@brenosantin9739
@brenosantin9739 7 жыл бұрын
Hail from Brazil, thanks for the class.
@sprakash1094
@sprakash1094 10 жыл бұрын
Go to your IIS then double click on Application Pool then on right hand side click on Set Application Pool Defaults after that in Process Model , Select Identity = local system.. its working for me . Thanks
@gururajjoshi1516
@gururajjoshi1516 10 жыл бұрын
Thanks for responding, but result is an error showing "Keyword not supported: 'v11.0; attachdbfilename'"
@al1980ful
@al1980ful 9 жыл бұрын
sprakash1094 thanks friend, that's it...
@jgarciascr5
@jgarciascr5 6 жыл бұрын
"The name of this connection string matches the name of our class EmployeeContext" ( 5:25 ) Does it mean we should have as many connection strings as context classes the application has? That does not sound very practical to me. If not, how can the different classes use one common connection string that lies within the web.config file?
@jgarciascr5
@jgarciascr5 6 жыл бұрын
The solution is to specify the connection string name in the context class constructor method: public YourContext() : base("name = YourConnectionName") { }
@AcheiversOfficial
@AcheiversOfficial 3 жыл бұрын
@@jgarciascr5 thanks for the question and answer.
@indranilpaul3945
@indranilpaul3945 8 жыл бұрын
"The property 'DeptId' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection where T is a valid entity type."
@AzizjanAyupov_leo
@AzizjanAyupov_leo 7 жыл бұрын
Thank you very much!!! It was exactly what I was needed!
@kushagrakhandelwal8867
@kushagrakhandelwal8867 3 жыл бұрын
Hi Venkat , I have a question, If we have multiple module classes then every time do we have to add the specific connection string in web config file? Can't we do that thing manually or isn't don net have something which automate that. Can you please make videos on newer concept too. So we can be up-to-date with newer concepts. There is no doubt your videos are awesome and no one can teach us like you do.
@saranshkumar8479
@saranshkumar8479 8 жыл бұрын
venkat sir, u rock yaar :)
@lbhatt
@lbhatt 7 жыл бұрын
Hi Venkat, After all, i am getting below error. could you please advice! An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: The underlying provider failed on Open.
@muhammadshaheer1648
@muhammadshaheer1648 5 жыл бұрын
I've a doubt, in the controller section why don't you pass employeecontext object in return view() paranthesis in order to rendering html view?
@ArifHussain-sq5fh
@ArifHussain-sq5fh 6 жыл бұрын
Thanks sir very helpful for beginners God give u long life
@EnKamran
@EnKamran 11 жыл бұрын
do i need to set : Database.SetInitializer(null) when i'm using Entity framework 6? i mean if i dont use this is it possible to delete my old data in my database?
@EnKamran
@EnKamran 11 жыл бұрын
i forgot to say i am using code first and my database creates runtime.
@evanflink7073
@evanflink7073 10 жыл бұрын
En Kamran Hi - no you do not add that line if you are using Code First. You only need it if you are using Database First (that is, you don't want your database to be created by EF) ,
@hetallcc
@hetallcc 8 жыл бұрын
Hi Venkat, I love the way you teach and for anything new i want to learn i always follow your series. its much better and the way you explain things is so clear and easy to understand. i have been following this successfully but now with this part 8 i am stuck and can;t go ahead. I am using visual studio 2013. and i have got error like Additional information: The underlying provider failed on Open. I have following exctlly what you are saying but just stuck here. do you have an idea what is this regarding and how can i fix it. Thanks kind Regards Hetal
@ypcingchikara
@ypcingchikara 8 жыл бұрын
+Hetal Patel It's related to the sql server provider, please add the following attribute and value to your connectionstring and it should work. network library=dbnmpntw; let us know in case you are still having problem.
@SouravBhattacharyaITFaculty
@SouravBhattacharyaITFaculty 9 жыл бұрын
I use sql server 2008 express, so I used .\SQLEXPRESS instead of . in the connection string and it worked for me, long live kudvenkat sir
@sagishorts2785
@sagishorts2785 8 жыл бұрын
hi, iam not clear with the Connection string part, how did you add it?
@SydurRahman21
@SydurRahman21 8 жыл бұрын
Hi kawshik sagi, I'm also agree with you. It is really confusing part. I'm still trying to do this part with my own but getting error!!!
@sagishorts2785
@sagishorts2785 8 жыл бұрын
Yes bro we need to find an answer or venkat need to tell???
@bhuwanpandey4342
@bhuwanpandey4342 8 жыл бұрын
@Kaushik Sagi Just in case you still have doubt Its exactly the same we do for a normal web application, we are just adding a sql server connection string to the ConnectionStrings section of the web.config Go to server explorer(ctrl+W, L or View -> Server Explorer) and connect to your database, once connected right click and select properties there you will find the Connection property something like "Data Source=DELL\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=True", just copy this and put it there in the connectionstring section of the config file, also keep the connectionstring name same as your Model class(EmployeeContext in the video). Hope this helps!!
@egl2004
@egl2004 8 жыл бұрын
Thank you SO much! This was extremely helpful and solved the problem. I really appreciate it!
@secretlives2734
@secretlives2734 8 жыл бұрын
can u guys tell me after connecting my database by adding connection string through server explorer it gives me error "an exception of type system .data.entity exception occurred in entity framework.sqlserver.dll bt not handled in user code. plz help me frnds "
@female1file
@female1file 9 жыл бұрын
SOLUTION: for anyone have this problem # EntityType 'Employee' has no key defined. Define the key for this EntityType# just add in employee class this word [Key] before EmployeeId property and add this also using System.ComponentModel.DataAnnotations;
@ashrafnazir701
@ashrafnazir701 8 жыл бұрын
Thanks a lot i got rid of this error :-)
@ayxanesedullayev3709
@ayxanesedullayev3709 4 жыл бұрын
wouw it worked thanks a lot i searched this error approximetely 4 hours)
@librairum2366
@librairum2366 4 жыл бұрын
Thanks for this solution fro my error about Entity error.
@kartheeknagulapati348
@kartheeknagulapati348 8 жыл бұрын
Folks who ever have a trouble creating a connection string with the DB in SQL Server Express, follow these steps: 1. First create a DB named Sample in SQL Server express 2. Add the necessary table named tblTable and data into it 3. Go to web.config file inside your visual studio MVC demo project 4. Open a connection string tag, and paste the below code into it: 5. Refresh the server explorer. 6. Your DB is connected.!! Thank you
@sureshmaddela4156
@sureshmaddela4156 8 жыл бұрын
hello venkat please solve this problem. An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code Additional information: The connection string 'EmployeeContext' in the application's configuration file does not contain the required providerName attribute."
@chetanchaudhari1408
@chetanchaudhari1408 6 жыл бұрын
Had your problem is solved? plese tell me he solution
@chetanchaudhari1408
@chetanchaudhari1408 6 жыл бұрын
[Table("UserProfile")] public class Employee { [Key] public int UserId { get; set; } public string UserName { get; set; } public string Password { get; set; } public bool IsActive { get; set; } } Add [Key ] Annotations like above ...Its works.
@lizravenwood5317
@lizravenwood5317 8 жыл бұрын
Dang you are a good teacher. So I am wanting to have a full grid view with CRUD operations that maps to a database. I want to be able to use datasets for looping and such, so I think I need the entity framework. Is it possible to do both? Oh - and another complication is that the database is not sql server but an Access table.
@dsingh3205
@dsingh3205 11 жыл бұрын
Thank you sir for the 8th part of MVC. Have a great day.
@AndrewErwin73
@AndrewErwin73 11 жыл бұрын
I have a question. It is my understanding of MVC that the model is not necessarily the data layer, but the business layer. My basic process is to create a whole separate project within my solution (even an MVC solution) for the datalayer. What do you suggest is the most efficient way to handle the "separation of concerns) when developing against MVC? I like the approach you take in this video, but it seems to go against my instinct. Thanks a lot for the videos! I do find them extremely helpful.
@sanaravi7
@sanaravi7 8 жыл бұрын
Hi Venkat Garu, I have some doubt. we are using SetInitializer function for already existing table in sample database. I try to using me created database it will showing SetInitializer throw exception. I tried using 'EmployeeContext.(null);" it will also get error. plz give me solution for this.
@lavanya4247
@lavanya4247 4 жыл бұрын
hi , when Context class is add automatically connection string will form or we have to add connection externally
@SaptarshiRoy05
@SaptarshiRoy05 4 жыл бұрын
We need to add externally
@girishdagdiya7555
@girishdagdiya7555 10 жыл бұрын
If you cannot find EntityFramework in references folder as shown in above video, then go to Tools> Library Package Manager> Package Manager Console and write "Install-Package EntityFramework -Version 5.0.0" , without double quotes. You will see Entity Framework in References folder now. :)
@viewsbyme
@viewsbyme 10 жыл бұрын
you are a champion!! thanks for the tip!!
@MrIrrepressible
@MrIrrepressible 10 жыл бұрын
nice one!!!
@shyammohanRaman
@shyammohanRaman 9 жыл бұрын
thanks!
@saikhasim6498
@saikhasim6498 6 жыл бұрын
thanq bro for this i searched 2 hours on web very useful..thanks bro
@fitkundan92
@fitkundan92 8 жыл бұрын
While trying to access data as shown in this video I am getting following exception "An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code" And I am not able to connect the database . Suggest something in this regard
@yazoo178
@yazoo178 8 жыл бұрын
I'm completely overwhelmed. I already have a connection string in my web config called DefaultConnection. Of course if I change this to EmployeeContext it will break stuff. Do I need to add another one? I'm confused towards why something abstract like a connection string would have such a strong coupling to something which specific deals with employees.
@raviranjan2901
@raviranjan2901 2 жыл бұрын
Dear Venkat, I'm using visual studio 2019 and sql server 2017 doing same process as in your video to fetch data from database, but i have some issue to execute. Login failed for user 'IIS APPPOOL\DefaultAppPool'. What does it mean
@kranthyreddy1023
@kranthyreddy1023 8 жыл бұрын
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 'MvcApplication2.Controllers.employeeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters Im getting this error when i run the program can u please help me out
@tara2010p
@tara2010p 8 жыл бұрын
make sure that '1' in address bar .../Employee/Details/1
@sandeep__gosavi
@sandeep__gosavi 6 жыл бұрын
A very useful video. Thanks buddy.
@mazdysoraya6121
@mazdysoraya6121 10 жыл бұрын
For those who get Error regarding SQL Connection. Within in web.config file, instead of using connectionString="data source=.; use Explicitly instance of your SQL server. connectionString="data source=computerName\sqlexpress; This error can occur if you for example have more then one instance of SQL ( like me ) so VIsual studio got confuse which to use. Hope this will solve problem for someone. I followed example exactly now it is working.
@TheNinjai74
@TheNinjai74 11 жыл бұрын
Hello Mr. Venkat! Great tutroial. I have added the the EntityFramework in Reference, but I notice in your WebConfig file there is a tag for 'EntityFramework' with a tag for 'defaultConnectionfactory type=""'. I'm not seeing this in my Webconig file. I'm currently using VS2013 Express. Thank you very much and great tutorials!
@rishikmani
@rishikmani 9 жыл бұрын
Hi Venkat, when I am trying to inherit DbContext class it shows error. Even though I have included the namespace System.Data.Entity. I have verified that under the references section, the System.Data.Entity and System.Data.Entity.Design are included as well. Could you please help?
@rishikmani
@rishikmani 9 жыл бұрын
Rishik Mani Tripathi Thank you... I solved it... I had to install the package through package manager console as well, it was only then I could inherit from DbContext. If anyone of you faces this issue, open package manager console from Tools, then type PM> Install-Package EntityFramework -Version 5.0.0
@nagarajjeela9731
@nagarajjeela9731 5 жыл бұрын
when I enter DbContext and DbSet ,I am not getting add using System.Data.Entity namespace in intellisense of vistal studio. How to fix this problem?
@alamgirkhan8334
@alamgirkhan8334 5 жыл бұрын
Dear bro. .First you need to install entity framework on your visual studio
@alamgirkhan8334
@alamgirkhan8334 5 жыл бұрын
For version 2017: Click 'Tools' Select 'NuGet Package Manager' press 'Manage NuGet Package Manage for solution..' Now in (NuGet Package Manage for solution) you have to click 'browse' then search Entity Framework Check project and install......
@naveenkumar-bz3rg
@naveenkumar-bz3rg 9 жыл бұрын
hi venkat, i got this error. The connection string 'EmployeeContext' in the application's configuration file does not contain the required providerName attribute." my con-string can you please resolve this , Thanks in advance.
@rajeshpradhan23
@rajeshpradhan23 9 жыл бұрын
You forgot to close connectionstring with " and start providerName with ". thats why u r getting error. Its should be
@hrvaticaigitara
@hrvaticaigitara 9 жыл бұрын
Rajesh Pradhan Can you please tell me what is wrong with that?? I get the same error with the providerName
@ankittrivedi2861
@ankittrivedi2861 8 жыл бұрын
Venkat Sir i m facing an 500 Internal Server Error. Please help me with it. can't find the solution to it. i have checked every thing every single line of code but still it is showing that error. And i wanted to ask what do u me by a sample database do we have to create a new database over take a built in db frm SQL server? i m confused in tht part also.
@anjanigarg1793
@anjanigarg1793 8 жыл бұрын
I was getting the same error message as everyone else were getting. Solution: I deleted the existing web.config file. (Make sure you save a copy of it in Notepad.) Run the program. New web.config file created. Got a different error. Checked what extra code was present in old web.config file and not present in new web.config file. Copied them to new web.config file. Run the program again. Worked. Hope this is helpful :)
@brunothebeagleofficial
@brunothebeagleofficial 8 жыл бұрын
Anjani Garg i am getting the same error, did you find any solution
@daalwada
@daalwada 5 жыл бұрын
Sometimes while Mapping in Employee class, it may throw an error saying "There is no Key defined in the class 'YourClassName'. Simple solution to it is to add a [Key] attribute with its namespace 'System.ComponentModel.DataAnnotations'
@eddiegere
@eddiegere 9 жыл бұрын
so many steps. lol. Very informative video on ASP.NET MVC. Thank you!
@quangdu12061988
@quangdu12061988 11 жыл бұрын
Hi Kudvenkat, I created a new project with the default template because I would like to re-use the built-in authentication function. But after I create a new EmployeeContext and change the name in ConnectionString in Web.config to EmployeeContext (original one is DefaultConnection), all the feature relates to authentication don't work anymore. When I revert it back to DefaultConnection, it works fine but cannot see the employee details. Is there any way to merge the contexts into one or how to change the connection string to make those functions can work together ? I really appreciate your contribution, your video helps me alot.
@quangdu12061988
@quangdu12061988 11 жыл бұрын
I found the answer myself, I am using MVC5 and if you go to IdentityModels.cs and change class ApplicationDbContext, it will work: public ApplicationDbContext() : base("YourContext") { } So happy :)
@Alii0007
@Alii0007 8 жыл бұрын
Very Very good tutorial. Thanks +kudvenkat. I am having an exception after doing all above, "Underlying Provider failed to open". Why DB is not opening?
@bharathk6596
@bharathk6596 4 жыл бұрын
Same error showing pls share the solve method sir...
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
3. Re-add the reference for the same assembly, from C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\EntityFramework.5.0.0\lib et40 Please Note: If you can't find the assembly at the above path, please use windows search feature to search for it. Still no success: Install Entity Framework 5.0 using NuGet Package Manager. Hope this solves the issue you have. Good Luck. Again, sorry for not answering in time.
@prakashkolluru
@prakashkolluru 11 жыл бұрын
Respected Sir, Im one of the Great fan of Ur's plz..! try to put some small projects which are helpful to develop any projects with respective Asp.net, Asp.Net MVC applications etc..! plz.. Give reply as soon as possible..!
@adilrasheed6441
@adilrasheed6441 8 жыл бұрын
+Venkat you are doing a great job!! Could you please upload some knockout js using MVC 5 as well.
@argelpamintuango1956
@argelpamintuango1956 8 жыл бұрын
what visual studio version are you using? because some of the tutorials that i follow on you is different and i am having a hard time fixing things.
@HemaRajamani
@HemaRajamani 11 жыл бұрын
kudvenkat, thanks for posting these videos, has been very helpful for me. About part 8 in particular, I kept getting 'IIS APPPOOL\ASP.NET v4.0' login error. I overcame that by adding this login to the security tab of Sql Server Management studio with windows authentication.
@ahmmady1
@ahmmady1 6 жыл бұрын
dear mr Vanket i have a problem the single method it gives me a message Sequence contains more than one element what should i do ? any suggest
@akshaysoren5400
@akshaysoren5400 6 жыл бұрын
i am getting this error at linq query: need help An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: An error occurred while executing the command definition. See the inner exception for details.
@bharathk6596
@bharathk6596 4 жыл бұрын
I am also same error sir pls share solve the method sir
@pravallikaannangi8940
@pravallikaannangi8940 8 жыл бұрын
Hi Venkat, I just followed your steps and got this error.. Can u please let me know the cause of this error. The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe. thank you!
@jeffersonalexandermosetonq4553
@jeffersonalexandermosetonq4553 7 жыл бұрын
Venkat, if i need use stored procedures from SQL Server how can i mapp it ?
@bhanumathi2841
@bhanumathi2841 7 жыл бұрын
Hi Sir. Please let me know, if it is mandatory to have primary key while working with models
@deepakthapa9528
@deepakthapa9528 8 жыл бұрын
i solved my problem.. we need to select visual studio development server instead of local iis server.
@VihaanKoul
@VihaanKoul 7 жыл бұрын
Yes this is correct.
@markorazumenic6915
@markorazumenic6915 7 жыл бұрын
thanks!!!!!
@jashjasani5045
@jashjasani5045 6 жыл бұрын
My vs doesn't have visual studio development server, what should i do?? any help accepteed..
@karthikrajakumar893
@karthikrajakumar893 7 жыл бұрын
I'm getting the error while i run the application in Asp.net MVC5 "Cannot attach the file mdf as database". Can i follow this tutorial for developing an Asp.net MVC project in visual studio 2015.
@HackbalLearning
@HackbalLearning 4 жыл бұрын
Visual Studio 2019 Community Edition kzbin.info/aero/PLfqaeumOCiRlm9UDBc0pBcKLCW2phN1Ie
@ganeshkamath89
@ganeshkamath89 7 жыл бұрын
is there no other way than to re-start some other ASP.net tutorial, if i have MySQL Db instead of MSSQL DB?
@nathanzhou8921
@nathanzhou8921 11 жыл бұрын
Another question is, does the fields' name of a table in database should match entity model class's fields' name? How does entity framework know mapping those fields to right columns in database? Thank you very much.
@yusufmohamedsalh8321
@yusufmohamedsalh8321 7 жыл бұрын
for any one will have an error after watching this video : check out @Antony Khomeriki comment 1- at models ->Emolyee.cs,add below lines (to set EmpID as primary key) using System.ComponentModel.DataAnnotations; [Key] public int EmpID { set; get; } 2-adjust connection string at Web.config ,note you can get full server name from sql studio ,your table name ,r.click ,properties ,server = full name 3- type the word Id as a parameter not any other variable and remmber to type it on the url ie : Employee/Details/1. public ActionResult Details(int id ) { EmpContext empcontext = new EmpContext(); Employee employee = empcontext.Get_All.Single(emp => emp.EmpID== id); return View(employee); 4- extra note , preferable to type the class members as the table members name.
@harikaaakutota7776
@harikaaakutota7776 11 жыл бұрын
hi venkat, here manually id =1 is entered in the url to retrieve a particular employee record.but in real time how does end user retrieves particular employee record?does he too enter id=1 in the url ?pls clarify this doubt...
@NazmulBilashHossain
@NazmulBilashHossain 9 жыл бұрын
I have facing problem in Employee employee = employeeContext.Employees.Single(x =] x.EmployeeId == id); I got error. What wll I do ? Please help me.
@rajeshpradhan23
@rajeshpradhan23 9 жыл бұрын
what error u r getting?
@jonsek5203
@jonsek5203 9 жыл бұрын
Rajesh Pradhan Hi i´m having the same issue!?Hope this helps! :) "The parameter dictionary contains a null entry for parameter 'id' of non nullable type 'System.Web.Mvc.ActionResult Details(int32) in .Controllers.EmployeeController. An omptional parameter must be a reference type, a nullable type or be delared as an optional parameter. Parametername: parameters"
@rishikmani
@rishikmani 9 жыл бұрын
Nazmul Hossain did you find a solution. I am also having the error at same line of code and am not able to start SQL Server Agent.
@575saikrishna
@575saikrishna 9 жыл бұрын
Nazmul Hossain i got the same error !!! i figured it out .... we need to give the same name EmployeeId in sql server ..it works fine for me
@priyaselvaraj1344
@priyaselvaraj1344 3 жыл бұрын
Hi Venkat, I'm using VS 2019 right now, unable to follow your first step because, I couldn't download entity framework from NuGet package manager, please do reply. Thank you!
@v.dprasad2196
@v.dprasad2196 Жыл бұрын
Hello Venkat sir, iam trying this code but it gives error, sometimes is Login failed for user 'IIS APPPooL\DefaultAppPool' and sometimes is system.data.entity.core.entityexception, login failed for user sa, until now am not getting output, so kindly plz share how to add sql table in sql server object explorer or server explorer.
@PraneethHarpanahalliPraneethh
@PraneethHarpanahalliPraneethh 9 жыл бұрын
I am getting the following error: "The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe." at the line Employee fk = emptr.Employer.Single(emp => emp.empage == id); Can someone help me
@turgaygulmez6901
@turgaygulmez6901 9 жыл бұрын
Praneeth Harpanahalli change your connection string as
@PraneethHarpanahalliPraneethh
@PraneethHarpanahalliPraneethh 9 жыл бұрын
Thanks I figured it out
@prayash20
@prayash20 2 жыл бұрын
Hello Venkat Sir, I am trying to perform the same operation using the Employee class with different model name different to Employee model. All the properties are same. I am getting the error of missing type while running the Controller. Can you guide me on this????
@davidespada01
@davidespada01 11 жыл бұрын
Hi Mr.Venkat cant i use the ADO.NET like the asp.net forms, because EF a little bit Hard to understand
@abhishekchauhan780
@abhishekchauhan780 7 жыл бұрын
I got a error , please help me out ..!!! Error:An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: An error occurred while executing the command definition. See the inner exception for details. I browsed a lot but cann't even find single solution. Also , i add [Key] attribute in model but didn't run app. successfully
@ShivaRamaKrishnaG
@ShivaRamaKrishnaG 8 жыл бұрын
Really helpful and very nice explanation
@mohitetv5380
@mohitetv5380 4 жыл бұрын
I am using VS 2015. I got this error : An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code . Please comment
@sameersk1
@sameersk1 8 жыл бұрын
Simply Great!!
@gururajjoshi1516
@gururajjoshi1516 10 жыл бұрын
Hi, i have done exact things which are shown in video, by adding some changes like Key attribute in model class, i had one more error "The underlying provider failed on Open", so i have added in EmployeeController class as public ActionResult Details(int id) { empolyeeContext empcon = new empolyeeContext(); empcon.Database.Connection.Open(); Employee empl= empcon.employees.Single(emp => emp.EmpId == id); But it started showing other error: Cannot attach the file 'D:\Working folder\MVCexamplePro\MvcDemo2\MvcDemo2\App_Data\MvcDemo2.Models.empolyeeContext.mdf' as database 'MvcDemo2.Models.empolyeeContext'. before staring this example i have created a DB in SQL Server 2008R2, with a small table wit columns as id,name,gender and city need help resolve this error
@sinraj0007
@sinraj0007 11 жыл бұрын
I am u r big fan ,U make dot net easy to understand.Can u upload Ajax video tutorial
Part 9  Generate hyperlinks using actionlink html helper
13:07
kudvenkat
Рет қаралды 544 М.
Part 10  Working with multiple tables in mvc
19:46
kudvenkat
Рет қаралды 585 М.
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Part 1   What is Entity Framework
18:02
kudvenkat
Рет қаралды 976 М.
Entity Framework Database First Approach | ADO.NET Tutorial
17:23
Naresh i Technologies
Рет қаралды 48 М.
Part 25  Insert update delete in mvc using entity framework
10:27
Part 11  Using business objects as model in mvc
16:21
kudvenkat
Рет қаралды 468 М.
Part 12  Creating a view to insert data using mvc
10:40
kudvenkat
Рет қаралды 458 М.
Creating your first aspnet mvc application - Part 3
12:30
kudvenkat
Рет қаралды 1,1 МЛН
Part 28   Customizing the autogenerated edit view
15:11
kudvenkat
Рет қаралды 129 М.
What is programming MVC? [Detailed Explanation]
24:40
DevMarketer
Рет қаралды 418 М.
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН