<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>Advanced Entity Framework Scenarios for an MVC Web Application (10 of 10)</title><link>http://www.asp.net</link><pubDate>Sat, 08 Oct 2011 01:25:04 GMT</pubDate><generator>umbraco</generator><description>Comments for Advanced Entity Framework Scenarios for an MVC Web Application (10 of 10)</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/33317" rel="self" type="application/rss+xml" /><item><title>Comment Posted by estuardogt</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Thu, 14 Apr 2011 11:14:34 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012804</guid><description><![CDATA[ <p>The tutorial is amazing! It&#39;s very simple to understand, and everybody must read it.</p><p>Congratulations and thanks for share it.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/estuardogt.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by hackamac</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sat, 23 Apr 2011 15:58:26 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012949</guid><description><![CDATA[ <p>&quot;In DepartmentController.cs, in the ValidateOneAdministratorAssignmentPerInstructor method, specify no tracking, as shown in the following example:</p><p>var duplicateDepartment = context.Departments</p><p>   .Include(&quot;Administrator&quot;)</p><p>   .Where(d =&gt; d.PersonID == department.PersonID)</p><p>   .AsNoTracking()</p><p>   .FirstOrDefault();&quot;</p><p></p><p>should be:</p><p></p><p>&quot;var duplicateDepartment = db.Departments</p><p>   .Include(&quot;Administrator&quot;)</p><p>   .Where(d =&gt; d.PersonID == department.PersonID)</p><p>   .AsNoTracking()</p><p>   .FirstOrDefault();&quot;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/hackamac.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by zoost</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sat, 23 Apr 2011 19:47:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012952</guid><description><![CDATA[ <p>This tutorial if fantastic, I learned alot. I have a request, in the not too distant future, will it be possible to have another tutorial with EF-CofeFirst in NTier MVC Application? Thanks</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/zoost.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Mon, 25 Apr 2011 14:23:10 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012960</guid><description><![CDATA[ <p>@hackamac - Thanks for reporting that.  The MVC 3 Tools Update scaffolding originally used &quot;context&quot; for the context variable name, and just before RTW that was changed to &quot;db&quot;. This was left over from some of the earlier scaffolded code.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by suresh_scribnar</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Mon, 25 Apr 2011 20:25:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012969</guid><description><![CDATA[ <p></p><p>This tutorial and the previous one was excellent. It allowed me quick start in MVC as I am experienced in ASP.NET 2.0. However, I found a fatal flaw in implementation of function ValidateOneAdministratorAssignmentPerInstructor.</p><p></p><p>The flaw/issue: ValidateOneAdministratorAssignmentPerInstructor logic (not the function) does not work in the system. Its still possible to have an instructor assigned as administrator for 2 departments.</p><p></p><p>How it would happen: Its a chance event however the all the logical errors that can be introduced in a system must be avoided even by chance events if its avoidable at all by the way business functions.</p><p></p><p>How to reproduce:</p><p> I have introduced a Thread.Sleep statement in functionValidateOneAdministratorAssignmentPerInstructor to reproduce this error.</p><p>1. Clear all departments to have no administrators.</p><p>2. Change the function ValidateOneAdministratorAssignmentPerInstructor as below. This line also introduces a static variable to reproduce the issue.</p><p>static int runCount = 0;</p><p>        private void ValidateOneAdministratorAssignmentPerInstructor(Department department)</p><p>        {</p><p>            </p><p>            if (department.InstructorID != null)</p><p>            {</p><p>                int count = runCount;</p><p></p><p>                Department duplicateDepartment = db.Departments</p><p>                    .Include(&quot;Administrator&quot;)</p><p>                    .Where(d =&gt; d.InstructorID == department.InstructorID)</p><p>                    .AsNoTracking()</p><p>                    .FirstOrDefault();</p><p>                //db.Entry(duplicateDepartment).Reference(x =&gt; x.Administrator).Load();</p><p>                if (duplicateDepartment != null &amp;&amp; duplicateDepartment.DepartmentID != department.DepartmentID)</p><p>                {</p><p>                    System.Diagnostics.Debug.WriteLine(&quot;Adding validation error.&quot;);</p><p>                    var errorMessage = String.Format(</p><p>                        &quot;Instructor {0} {1} is already administrator of the {2} department.&quot;,</p><p>                        duplicateDepartment.Administrator.FirstMidName,</p><p>                        duplicateDepartment.Administrator.LastName,</p><p>                        duplicateDepartment.Name);</p><p>                    ModelState.AddModelError(string.Empty, errorMessage);</p><p>                    System.Diagnostics.Debug.WriteLine(&quot;Added validation error.&quot;);</p><p>                }</p><p>                if ((runCount % 2) == 0)</p><p>                {</p><p>                    System.Threading.Thread.Sleep(15000);</p><p>                }</p><p>                else</p><p>                {</p><p>                    System.Threading.Thread.Sleep(15000);</p><p>                }</p><p>            }</p><p>        }</p><p>3. Now run the app and open edit page of one department, say &quot;Mathematics&quot;.</p><p>4. Now open another explorer tab or window and open edit page of another  department, say &quot;Engineering&quot;.</p><p>5. Choose same administrator/instructor name for both.</p><p>6. Submit both. Ensure that both department updates are submitted ASAP.</p><p>7. You will see that the second submission(most probably) coming with same admin selected for both departments in index page.</p><p></p><p></p><p>This issue can be solved easily by following true(or somewhat) OOP code by not having InstructorID field in Department model class. That means, the Instructor table would be created with Department_ID field by EF. This way you will get concurrency exception and the user is informed even though you may have a table that in database is not good as per db standards. Or you can keep the same structure and still overcome this by having a SP handle the the update that a DbContext(I am still not knowledgeable enough whether its possible; as the time I checked, it was not possible) would call and that SP would lock the Department table row and check if an admin is assigned to another department and then update that department row and then unlock. Since db lock is there, another process trying to update would wait or timeout.</p><p></p><p>However, this issue highlights how various logical errors can be introduced in a system using DbContext that has a ForeignKeyId field and also associated object unless the developer is aware of. That means, there could be many people having this issue without realizing that they may have. So, my question is how is EF with code first trying to solve this kind of issues? Kindly let me know as this is a major issue and if code first is used in a system with more than 10s of objects which are interrelated then this issue would definitely happen.</p><p></p><p>Thanks</p><p>Suresh</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/suresh_scribnar.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 26 Apr 2011 01:30:25 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012974</guid><description><![CDATA[ <p>@Suresh - Thank you for the detailed explanation of your findings.  For this tutorial, the ValidateOneAdministrator method was introduced as a fairly simple way to illustrate one use of AsNoTracking.  As you point out, if this were a business requirement for a real application you could enforce it more effectively by using a different database design. Any database design including your proposal can be modeled using Code First; what you see in these tutorials is not the full range of what can be done in Code First but is a sample application that illustrates as many features as possible in a limited amount of relatively simple code. For more in-depth coverage of Code First capabilities you can explore some of the links to other Entity Framework resources at the end of the tutorial.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by suresh_scribnar</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 26 Apr 2011 13:07:21 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012983</guid><description><![CDATA[ <p>@tdykstra: Thanks for the response. Yes, I understood that its a sample to show EF capabilities than showing proper design techniques. I should have put that disclaimer already ;-)</p><p></p><p>Thanks again for the great tutorial and the response.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/suresh_scribnar.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by suresh_scribnar</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 26 Apr 2011 13:09:17 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012984</guid><description><![CDATA[ <p>I still wonder, Does Code First support call to custom stored procedures? Or can raw sql calls be used to call SQL Stored procedures? Any link would be sufficient, thanks.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/suresh_scribnar.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 26 Apr 2011 13:57:07 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012987</guid><description><![CDATA[ <p>@suresh - Sorry, but automated Stored Procedure support is one thing that was dropped in order to deliver Code First earlier.  It&#39;s planned for a future release.  By automated I mean where you set up EF to automatically use sprocs when you do normal CRUD operations using the DbSet properties -- you can call sprocs manually using the raw sql methods shown in this tutorial.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by joshwilliams81</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 26 Apr 2011 16:24:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012993</guid><description><![CDATA[ <p>Best, and most up to date tutorial I have seen yet. Great job! I&#39;ve built sites with LINQ to SQL and MVC before but the next one I do will be with EF + MVC3.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/joshwilliams81.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Xequence</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Fri, 20 May 2011 10:38:50 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013227</guid><description><![CDATA[ <p>public ActionResult Index(int? SelectedDepartment)</p><p>{</p><p>    var departments = unitOfWork.DepartmentRepository.Get(</p><p>        orderBy: q =&gt; q.OrderBy(d =&gt; d.Name));</p><p>    ViewBag.SelectedDepartment = new SelectList(departments, &quot;DepartmentID&quot;, &quot;Name&quot;, SelectedDepartment);</p><p></p><p>    int departmentID = SelectedDepartment.GetValueOrDefault(); </p><p>    return View(unitOfWork.CourseRepository.Get(</p><p>        filter: d =&gt; !SelectedDepartment.HasValue || d.DepartmentID == departmentID,</p><p>        orderBy: q =&gt; q.OrderBy(d =&gt; d.CourseID),</p><p>        includeProperties: &quot;Department&quot;));</p><p>}</p><p>should be</p><p></p><p>includedproperties:&quot;Department&quot;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Xequence.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Xequence</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Fri, 20 May 2011 10:39:37 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013228</guid><description><![CDATA[ <p>id like to edit my comment and add that these tutorials are awesome</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Xequence.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sun, 22 May 2011 11:35:12 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013246</guid><description><![CDATA[ <p>@Xequence - Thanks for the compliment. In the previous tutorial the parameter is defined as &quot;includeProperties&quot;, not &quot;includedProperties&quot;. If you get a compile error on this code, an extra &quot;d&quot; may have been inserted in the repository code.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by weedcontroller</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Fri, 24 Jun 2011 09:56:35 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013606</guid><description><![CDATA[ <p>This is a greate tutorial, why can&#39;t they all be like this?</p><p></p><p>I found it very easy to follow as a total novice thats done little more than experiment before. Thanks for the help!</p><p></p><p>@Xequence: I have found that using the intelisence system means that whatever you named a method (ect) doesn&#39;t really matter as it will come out right as long as you pay attension to the screen output as you type. In theory you could have called the &#39;includedProperties:&#39; propertiesIWant: and the effect would still be the same.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/weedcontroller.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by weedcontroller</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Fri, 24 Jun 2011 10:20:21 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013607</guid><description><![CDATA[ <p>Further notes:</p><p></p><p>I have been doing some studying on the subject of MVC3 Scaffolding and believe that the following link will be very usefull, I have put some of it to good use when working through this tutorial and saved myself some work! Always a good thing!</p><p></p><p><a rel="nofollow" href="http://blog.stevensanderson.com/category/mvc/" target="_blank">blog.stevensanderson.com/</a></p><p></p><p>It covers the Scaffolding features that you can control from the package manager in VS. I found it quite surprising just how much of the coding work can be done for you, in many cases writing a basic class file is all you need to get a complex site built in only a few steps!</p><p></p><p>Give it a go!</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/weedcontroller.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by silvergrey</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sat, 25 Jun 2011 21:00:36 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013618</guid><description><![CDATA[ <p>And &#39;To do that, you&#39;ll create a dedicated CourseController class that derives from the GenericController class.&#39; should read, &#39;To do that, you&#39;ll create a dedicated CourseRepository class that derives from the GenericRepository class.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/silvergrey.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by traemarshall</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sun, 03 Jul 2011 19:44:07 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013671</guid><description><![CDATA[ <p>&gt;&gt;Queries can be too long to display in the debugging windows </p><p>&gt;&gt;in Visual Studio. To see the entire query, you can copy the </p><p>&gt;&gt;variable value and paste it into a text editor:</p><p></p><p>One can also hover over the &#39;Value&#39; and get a formatted tooltip. Just in case anyone here was unaware of this.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/traemarshall.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Mon, 04 Jul 2011 14:55:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013688</guid><description><![CDATA[ <p>@silvergrey - Thanks for reporting that, I will fix it.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mvcvm</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sat, 16 Jul 2011 02:44:30 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013769</guid><description><![CDATA[ <p>Really appreciate the effort and care that has gone into this tutorial.</p><p></p><p>One question:</p><p>The navigation property always has a plural noun name and points to an entity set having a singular noun name e.g. Instructor.Courses -&gt; Course and Instructor.Departments -&gt; Department. </p><p></p><p>In the latter case, it&#39;s not obvious that the Instructor &quot;directs&quot; or &quot;heads&quot; the Department(s) which is why I might want to use verb names.</p><p></p><p>If the navigation property is renamed, will there be ill effects? Will scaffolding still work? Can metadata attributes be applied to assist?</p><p></p><p>Thank you and great work!</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/mvcvm.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Fri, 29 Jul 2011 18:27:53 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013879</guid><description><![CDATA[ <p>@mvcvm - Scaffolding does not depend on the name. There&#39;s an example of this in this data model, since in the Department class the navigation property named Administrator holds an Instructor entity.  You can name the property however you want, and scaffolding will look at the type of the property to determine its role as a navigation property.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by alftoo</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 02 Aug 2011 10:31:56 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013889</guid><description><![CDATA[ <p>Good job on a very clear and consistent tutorial! Only this last part caused me some confusion. Not sure if these are errors or if I failed to follow the instructions properly:</p><p></p><p>- Each of the 3 last bullets explaining the sequence of events leading to the &quot;ObjectStateManager cannot track...&quot; error contain references to &quot;the Update method of the department repository&quot; calling &quot;Attach&quot;, even though DepartmentController.cs instantiates its own SchoolContext and uses it directly without a repository.</p><p></p><p>- Under the subtitle &quot;Examining Queries Sent to the Database&quot;, instructions are to &quot;set a breakpoint in GenericRepository.cs on the return query.ToList(); statement of the Get method&quot;. It worked as intended the first time around, but after the Index method of CourseController.cs was replaced by a version which passes &quot;orderBy&quot; to the Get() method of the Repository, the breakpoint didn&#39;t get hit anymore. Inserting breakpoints on both return statements in the Get() method made it work. Even so, the SQL query that was revealed was somewhat different from the one in the tutorial (all the rows starting [Project1] were missing, as was the ORDER BY clause). I guess this was because the breakpoint that was hit was for the statement &quot;return orderBy(query).ToList();&quot;, i.e. orderBy had probably not yet been baked into the query.</p><p></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/alftoo.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Tue, 23 Aug 2011 15:55:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014029</guid><description><![CDATA[ <p>@alftoo - Thanks for the error report.  The text in the ObjectStateManager error explanation came from the Web Forms / Database First tutorial and is not accurate for this one. The breakpoint instructions also need to be clarified. These will be corrected in the next tutorial update.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by TheGDizzo</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Mon, 26 Sep 2011 15:49:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014276</guid><description><![CDATA[ <p>In regards to the part of this tutorial listed below...</p><p>===</p><p>In CourseController.cs, call the new method from the Details method, as shown in the following example: </p><p></p><p>public ActionResult Details(int id) </p><p>{ </p><p>    var query = &quot;SELECT * FROM Course WHERE CourseID = @p0&quot;; </p><p>    return View(unitOfWork.CourseRepository.GetWithRawSql(query, id).Single()); </p><p>}</p><p>===</p><p></p><p>I did not find a &quot;Details&quot; method that is of type &quot;ActionResult&quot; within the existing code in CourseController.cs.  I went ahead and replaced the &quot;Details&quot; method of type &quot;ViewResult&quot; with this code snippet, and it seems to work... but what&#39;s the difference between a &quot;ViewResult&quot; and an &quot;ActionResult&quot; and when would I know to use one vs. the other?</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by tdykstra</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Thu, 06 Oct 2011 15:46:35 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014350</guid><description><![CDATA[ <p>@ThGDizzo - Thanks for pointing out that inconsistency.  It will be fixed in the next release of the tutorial. For an explanation of ViewResult vs. ActionResult, see:</p><p><a rel="nofollow" href="http://forums.asp.net/t/1448398.aspx" target="_blank">forums.asp.net/</a></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by TheGDizzo</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application</link><pubDate>Sat, 08 Oct 2011 01:25:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014358</guid><description><![CDATA[ <p>I&#39;m wondering if some itermediate steps in the tutorial are missing between these two points.</p><p></p><p>(Point A)</p><p>Run the Department Edit page and try to change a department&#39;s administrator to an instructor who is already the administrator of a different department. You get the expected error message:</p><p>&lt;Here is display a PrtScr of &quot;English&quot; Department Edit page showing that Fadi Fahkouri is already an administrator of Mathematics department.&gt;</p><p></p><p>(Point B)</p><p>Now run the Department Edit page again (are you saying select &quot;back To List&quot; then select to &quot;Edit&quot; this exact same page again? Or are you saying clear the selection for Administrator and proceed to edit the Budget amount for this current record?) and this time change the Budget amount. When you click Save, you see an error page:</p><p></p><p>Uh... No... no I didn&#39;t actually... it merely accepted my change to the Budget field, then returned to the Department Index.</p><p></p><p>Then the next block of text tries to describe the sequence of events that led to this &quot;error&quot; that I didn&#39;t have occur...</p><p></p><p>•The Edit method calls the ValidateOneAdministratorAssignmentPerInstructor method, which retrieves all departments that have Kim Abercrombie as their administrator. That causes the English department to be read. Because that&#39;s the department being edited, no error is reported. As a result of this read operation, however, the English department entity is now being tracked by the database context.</p><p></p><p>Right off the bat... this blurb of text mentions a specific Instructor of &quot;Kim Ambercombie&quot;. As best as I can figure, since I&#39;m not achieving this error page talked about... I&#39;m thinking there were perhaps some more specific instructions to carry-out for the user actions I was supposed to perform in sequence in order to make the error occur for me so that I could have the lesson trying to be taught go full-circle for me conceptually?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635071778400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>