I download your project example. when I click the page, it show can't find dbo.student. I try to look database table but I don't see that student table, just see Course, CourseInstructo
r, Department, Enrollment, OfficeAssignmen t and Person. what happen?
Try changing the database name in Web.config and running update-database again.
Hi Tom how can I manage unique constraint please.
For questions not about the sample/tutorial itself, see StackOverflow or the ASP.NET EF forum (links at the top of the first page in the tutorial series).
hi Tom can i please have the documentation to c how the code flows please please its working perfect
See the Description tab -- there's a link to the tutorial series that shows how to build the application from scratch.
.com report please Tom
Hi Tom: I can't attach file CU10.mdf to database. Do you have any script to do that?
If you mean update-database creates the file but it won't attach, chances are you already used the CU10 name. Go into Web.config and change the name of the database or delete the existing database. For instructions on how to change the name, see the note near the end of the fourth tutorial: http://www.asp.
net/mvc/tutoria ls/getting-star ted-with-ef-5-u sing-mvc-4/crea ting-a-more-com plex-data-model -for-an-asp-net -mvc-applicatio n
HI Tom : Can't find database CU10.mdf......A
pp_Data folder is empty
In the Description under Getting Start there are build and run instructions -- one of the steps is to run the Update-Database command. That creates the database; the database .mdf file isn't included in the download.
Hi Tom: When I tried to run your application, everything worked until it tried to attach the file CU10.mdf to the database whereupon it choked. I couldn't find this file anywhere in the download. Am I missing something? Roger S
Whoops - I guess my local system doesn't handle attach well - removed that from the connection strings and database built like a charm - thanks - looking forward to going though this. Roger
I too encountered this error in the Package Manager after running 'Update-Databas
e' to set up the project. The error I received was: Cannot attach the file 'C:\Users\Rich\ Documents\Visua l Studio 2013\Projects\E FCF\C#\ContosoU niversity\App_D ata\CU10.mdf' as database 'CU10'. The reason for this was that I had previously set the solution up and an instance of the CU10 database was already attached. To resolve I logged into the '(LocalDB\v11.0 )' dataabse in SQL Server Management Studio and deleted the CU10 database that was there. I reran the command and all is well once again in LaLa Land.
Hi Tom, as described in "MVC ModelBinding Vulnerability in Contoso University sample (first raw PoC)" http://blog.din
iscruz.com/2013 /07/mvc-modelbi nding-vulnerabi lity-in.html there are a number of MVC ModelBinding Vulnerabilities in this application. I would like to use this application has an example of how to fix these issues, so have you added this code to GitHub? (so that I can fork it and make my code changes there?)
We've updated the application both here in Code Gallery and on the archive.msdn site where the chapter downloads are stored. I'm not aware that there is a copy of this project on GitHub -- if someone has put one there I don't have control over it. The download project shows one method to address the vulnerability - using the Bind attribute. Another method is to use view models and not bind directly to entity classes. The options are discussed in a new security note sidebar in tutorial #2.
I believe it is better to rely on the available links in Gallery MSDN
I have the E-Book "Getting Started with the Entity Framework 4.1 Using ASP.NET MVC".pdf which states that the requirements are VS 2010 SP1. I've fulfilled that and the other requirements. However, the link "download the completed application" brings me HERE and the requirements to create, build and run the sample are now different. So, where is the source code to the VS 2010 MVC 3 version? I don't WANT to build the "latest" version - for a SPECIFIC REASON.
Here's a link to the C# MVC 3 project: http://archive.
msdn.microsoft. com/Project/Dow nload/FileDownl oad.aspx?Projec tName=aspnetmsd nexamples&Downl oadId=16474 We forgot to re-post the old version somewhere when we updated the sample for MVC 4 EF 5.
Thank you, Tom. Much appreciated.
I like your app so much and your work is highly appreciated. I just have two questions for you: In Department controller: 1-private SchoolContext db = new SchoolContext()
; how the database connection(from web.config) is passed to schoolcontext instance 2-in index action, you use db.department Where is department initialized? Thank you in advance
1. EF looks for a connection string with the same name as the context class. See the first tutorial in the series for more information about this. 2. Departments DbSet property is defined in the context class. See the first and fourth tutorials in the series for more information about this.