<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Reading Related Data with the Entity Framework in an ASP.NET MVC Application (5 of 10)</title><link>http://asp.net</link><pubDate>Wed, 16 May 2012 14:58:08 GMT</pubDate><generator>umbraco</generator><description>Comments for Reading Related Data with the Entity Framework in an ASP.NET MVC Application (5 of 10)</description><language>en</language><atom:link href="http://asp.net/rss/comments/33312" rel="self" type="application/rss+xml" /><item><title>Comment Posted by hack_cat</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 07 May 2011 11:27:10 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013095</guid><description><![CDATA[ <p>Greate,but you&#39;ve forgot to add FullName field of Student entity in the toturial.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/hack_cat.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 10 May 2011 17:35:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013126</guid><description><![CDATA[ <p>@ hack cat - It&#39;s not in the first tutorial but it&#39;s in #4 and should be there for this one.  Where is it missing?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by avprod1</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 03 Jun 2011 15:23:07 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013383</guid><description><![CDATA[ <p>There may be a typo with the class name assignment for highlighted table rows; class name is case-sensitive (at least in Firefox). In Site.css the new class is &quot;.selectedRow&quot; and this creates a lower-case class name: </p><p>if (item.CourseID == ViewBag.CourseID) </p><p>        { </p><p>            selectedRow = &quot;selectedrow&quot;; </p><p>        } </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/avprod1.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by michaelfourtwo</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 06 Jun 2011 20:09:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013431</guid><description><![CDATA[ <p>My &quot;.selectedRow did not appear to work until I change the color from #EEEEEE to somethine else. I believe #EEEEEE was displayed as white? so there was no apparent color change. </p><p></p><p>Once I change the color everything worked fine. My browser is IE 8.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/michaelfourtwo.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 07 Jun 2011 17:46:54 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013444</guid><description><![CDATA[ <p>@avprod1 - the variable name is selectedRow, but its value is &quot;selectedrow&quot; which is what goes into the HTML.</p><p></p><p>@michaelfourtwo - #EEEEEE is not white, more like a light grey; when it did not seem to be appearing, one possibility is that you did not click refresh/reload in your browser; CSS changes may not be picked up until you do that.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by michaelfourtwo</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 07 Jun 2011 23:58:08 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013448</guid><description><![CDATA[ <p>I did the refresh as recommended in the tutorial. It made no difference. If I put #EEEEEE back in the select color does not appear. I guess it is my display. Thanks,</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/michaelfourtwo.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by frez</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 08 Aug 2011 10:56:50 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013928</guid><description><![CDATA[ <p>Typo: &quot;While you still have Views\Instructors\Index.cshtml open&quot; Instructors should be singular, i.e. Instructor.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/frez.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mvcvm</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 10 Aug 2011 05:54:01 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013941</guid><description><![CDATA[ <p>Although [NullDisplayText = &quot;No grade&quot;)] is set on Enrollment.Grade, it only works correctly in the Student Details page. In the Instructors page described here, a null grade is shown as blank, at least on my PC.</p><p></p><p>Anyone else seeing this?</p><p></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/mvcvm.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ldellj</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 19 Aug 2011 14:15:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013993</guid><description><![CDATA[ <p>Same thing happens to me. In Student/Details view &quot;No grade&quot; shows up for a null value, but in the Intructor/Index view it is blank.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ldellj.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ldellj</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 19 Aug 2011 14:43:49 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013994</guid><description><![CDATA[ <p>In that column on the Instructor/Index view, I changed:</p><p>@item.Grade to</p><p>@Html.DisplayFor(modelItem =&gt; item.Grade) then it shows the &quot;No grade&quot; string.</p><p>I talked about it with another developer and I believe what happens is @item.Grade just directly calls the value, where if you use the helper it passes it as a parameter to the helper and then applies the annotation.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ldellj.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 23 Aug 2011 15:07:23 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014025</guid><description><![CDATA[ <p>@frez, idellj, and mvcvm - Thanks for the error and solution reports, I&#39;ll fix in the next tutorial update.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by riddelrp</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 05 Sep 2011 08:19:31 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014125</guid><description><![CDATA[ <p>So, when do you use explicit loading?</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/riddelrp.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 08 Sep 2011 17:36:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014157</guid><description><![CDATA[ <p>@riddelrp - One scenario might be a case where eager loading would result in complex and inefficient queries, and relying on lazy loading would also be inefficient.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jrichview</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 30 Sep 2011 17:18:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014309</guid><description><![CDATA[ <p>I&#39;m finding that Firefox won&#39;t show the background color of the selected row regardless of what color I use. Same exact code in IE shows the CSS color.  So maybe Firefox handles CSS differently. Currently using 6.0.2 of Firefox because one of my plugins doesn&#39;t support newer version yet.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/jrichview.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by maximusmd</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 10 Oct 2011 15:43:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014381</guid><description><![CDATA[ <p>just curious: why you use this statement:</p><p>return View(instructors.ToList()); isntead of just:</p><p>return View(instructors);</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/maximusmd.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by maximusmd</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 10 Oct 2011 15:43:21 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014382</guid><description><![CDATA[ <p>just curious: why you use this statement:</p><p>return View(instructors.ToList()); isntead of just:</p><p>return View(instructors);</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/maximusmd.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by maximusmd</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 11 Oct 2011 18:43:29 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014402</guid><description><![CDATA[ <p>How do I display &quot;N/A&quot; when the office value is null? Like you did with Grades with the line below:</p><p></p><p>        [DisplayFormat(DataFormatString=&quot;{0:#.#}&quot;,ApplyFormatInEditMode=true,NullDisplayText=&quot;No grade&quot;)] </p><p></p><p>Can that be done in one of the Model classes or we need to check if the value is null in View? -- thanks</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/maximusmd.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by geomar</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 13 Oct 2011 13:46:36 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014422</guid><description><![CDATA[ <p>Last section discussing explicitly loading Enrollments uses the same code as the eager loading:&#160;</p><p></p><p>viewModel.Enrollments = viewModel.Courses.Where(x =&gt; x.CourseID == courseID).Single().Enrollments; </p><p>    }</p><p></p><p>I think you meant to do this instead:</p><p></p><p>viewModel.Enrollments = selectedCourse.Enrollments;</p><p></p><p>Otherwise there was no reason to do the explicit loading. </p><p> </p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/geomar.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 19 Oct 2011 21:29:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014459</guid><description><![CDATA[ <p>@maximusmd - Either way (calling ToList or not) works. Calling ToList causes the query to be executed and the rows to be returned in order to create the List, but you could defer this to the view. In a Web Forms application, in some cases you can get in a situation where if you don&#39;t use ToList, the context ends up getting disposed before the UI code is executed, and then you get an exception.  ...  For the office value N/A you&#39;d need to check for null in the view.</p><p>@geomar - You&#39;re right, that code would be simpler, and I&#39;ll adopt it in the next release of the tutorial, but without the explicit loading, the Enrollments wouldn&#39;t have their Student navigation properties loaded.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by louis745</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 08 Nov 2011 20:36:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014586</guid><description><![CDATA[ <p>When I try to delete an instructor (and he is administrator in department table, I got this error :</p><p></p><p>Server Error in &#39;/&#39; Application.</p><p>--------------------------------------------------------------------------------</p><p></p><p>The DELETE statement conflicted with the REFERENCE constraint &quot;Department_Administrator&quot;. The conflict occurred in database &quot;School&quot;, table &quot;dbo.Department&quot;, column &#39;InstructorID&#39;.</p><p>The statement has been terminated. </p><p></p><p>If I remove manually InstructorId in Department, I got the same error but whit the OfficeAssignment.</p><p></p><p>Any Idea?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/louis745.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by maximusmd</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 11 Nov 2011 13:04:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014608</guid><description><![CDATA[ <p>When you delete an Instructor, how does EF handles the deletion of the records on the other Entities? do we need to set cascade somewhere?</p><p></p><p>Thanks</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/maximusmd.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 28 Nov 2011 13:35:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014712</guid><description><![CDATA[ <p>@louis745 - That is a result of the database enforcing referential integrity. In a production application, you would catch this error and warn people that they need to delete related data first (in this case, the administrator assignment), or set up cascade delete so that this happens automatically.</p><p>@maximusmd - In certain cases, such as the automatically created many-to-many association tables, Code First sets up cascade delete rules by default; in other cases you would specify it manually using fluent API method calls.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by srdjan_r</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 26 Apr 2012 17:50:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015419</guid><description><![CDATA[ <p>Great tutorial so far. But I am stuck on this chapter. I get an error like this: </p><p>&quot;A specified Include path is not valid. The EntityType &#39;ContosoUniversity.DAL.Instructor&#39; does not declare a navigation property with the name &#39;LastName&#39;.&quot;</p><p>A specified Include path is not valid. The EntityType &#39;ContosoUniversity.DAL.Instructor&#39; does not declare a navigation property with the name &#39;LastName&#39;.</p><p></p><p>What is wrong?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/srdjan_r.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by fogjuice</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 02 May 2012 19:46:37 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015446</guid><description><![CDATA[ <p>Great set of tutorials on the EF and ASP.NET MVC!</p><p></p><p>How about using the knowledge gained on eager loading in this tutorial to go back and optimize the queries in the /Student/Details/id page?</p><p></p><p> Student student = db.Students</p><p>             .Include(s =&gt; s.Enrollments.Select(e =&gt; e.Course))</p><p>             .Where(s =&gt; s.StudentID == id)</p><p>             .Single();</p><p></p><p>I&#39;d give a more detailed explanation why I did this and how to do it, but it seems like the comment length is limited.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/fogjuice.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 16 May 2012 14:58:08 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015529</guid><description><![CDATA[ <p>@fogjuice - Thanks for the suggestion. In a production app you would make those sorts of changes, but it isn&#39;t always the best use of tutorial time to go back and change earlier code after introducing a new concept or technique.  We do that sometimes, though, and I&#39;ll keep the suggestion in mind for the next release of the tutorial.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635047081800000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>