<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>Updating Related Data with the Entity Framework in an ASP.NET MVC Application (6 of 10)</title><link>http://asp.net</link><pubDate>Mon, 18 Jul 2011 16:29:27 GMT</pubDate><generator>umbraco</generator><description>Comments for Updating Related Data with the Entity Framework in an ASP.NET MVC Application (6 of 10)</description><language>en</language><atom:link href="http://asp.net/rss/comments/33313" rel="self" type="application/rss+xml" /><item><title>Comment Posted by airmaro</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 20 Apr 2011 16:29:15 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012890</guid><description><![CDATA[ <p>The code block below the following paragraph should have @Html.LabelFor(model =&gt; model.Courses) instead of @Html.LabelFor(model =&gt; model.OfficeAssignment.Location)</p><p></p><p>In Views\Instructor\Edit.cshtml, add a Courses field with an array of check boxes by adding the following code immediately after the div elements for the OfficeAssignment field:</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/airmaro.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 20 Apr 2011 17:54:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012893</guid><description><![CDATA[ <p>Thanks for the note -- the courses field is created by the following div elements and this div element is not needed in the code block as it should already exist in the view, so I&#39;ve removed it. </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by fredbear7232</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 16 May 2011 10:43:07 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013185</guid><description><![CDATA[ <p>for some reason when I&#39;m going thru the tutorial and I try to use the edit code provided, I keep getting this exception: A first chance exception of type &#39;System.Data.Entity.Infrastructure.DbUpdateConcurrencyException&#39; occurred in EntityFramework.DLL.  </p><p></p><p>Maybe I should go thru the concurrency tut before I post this? :) But it seems wierd because it&#39;s ONLY the edit page. the creat/delete pages work just fine. Any thoughts?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/fredbear7232.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 22 May 2011 11:08:37 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013242</guid><description><![CDATA[ <p>@ fredbear7232 - I haven&#39;t seen that exception.  My first thought is to make sure you have the latest EF 4.1 (not an earlier CTP or RC). You might also download the sample project and see if you get the error there to determine whether there&#39;s something about your machine setup. There is an EF bug in concurrency-related code that is related to machine setup, and this could also be another manifestation of that issue.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by kingab</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 29 May 2011 01:15:06 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013306</guid><description><![CDATA[ <p>I found that when adding the code to display the CourseID in Views\Course\Edit.cshtml, I had to use an EditorFor field instead of a DisplayFor field.  Otherwise it errored out when trying to save changes to a course, such as adjusting the number of credits.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/kingab.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by kingab</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 29 May 2011 01:16:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013307</guid><description><![CDATA[ <p>P.S. - Great tutorial!</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/kingab.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 31 May 2011 11:59:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013341</guid><description><![CDATA[ <p>@kingab - I am not able to reproduce that error -- I have no trouble saving changes in the Course Edit page with the DisplayFor field being used for the CourseID. Can you provide more information about the error you were getting?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gorthon</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 04 Jun 2011 16:04:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013408</guid><description><![CDATA[ <p>I also found that when adding the code to display the CourseID in Views\Course\Edit.cshtml, I had to use an EditorFor field instead of a DisplayFor field. If I don&#39;t the &quot;Unable to save changes&quot; message shows and the course number shows 0. I commented out the try catch and I get an DBUpdateConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries. I pasted over with the code from the example and still get the same error. </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/gorthon.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mherdotinfo</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 05 Jun 2011 16:18:26 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013412</guid><description><![CDATA[ <p>I confirm the error Kingab and gorthon mentioned.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/mherdotinfo.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mherdotinfo</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 05 Jun 2011 16:18:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013413</guid><description><![CDATA[ <p>good tutorial</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/mherdotinfo.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 07 Jun 2011 18:06:32 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013445</guid><description><![CDATA[ <p>@kingab, gorthom, or mherdotinfo - Do you get this error if you download the application from Code Gallery (that project uses the DisplayFor helper)?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gary7101</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 25 Jun 2011 14:55:53 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013613</guid><description><![CDATA[ <p>When adding the code block for the check box array, (Views\Instructor\Edit.cshtml) the html does not validate and cannot compile. I get intellisense errors on the table row tags. I&#39;ve directly copied the code from this page, as well manually entered, but it will not validate. Error on the tr tag says text is not allowed between the opening and closing tag.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/gary7101.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gary7101</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 25 Jun 2011 15:32:23 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013615</guid><description><![CDATA[ <p>My apologies for this question: Why is the downloadable source code not the same as the tutorial?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/gary7101.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gary7101</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 25 Jun 2011 15:35:37 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013616</guid><description><![CDATA[ <p>Sorry, please disregard my last post. I found the correct download.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/gary7101.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gary7101</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 25 Jun 2011 16:00:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013617</guid><description><![CDATA[ <p>In regards to my first post related to tag errors; I&#39;ve resolved the compiler error which was due to an omitted line of code in the InstructorController code. However, the table row tags continue to cause intellisense to claim errors. This does not seem to be a problem in running the project, but is annoying when working in the editor!</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/gary7101.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 04 Jul 2011 14:36:00 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013684</guid><description><![CDATA[ <p>@gary7101 - Sorry, the download link is incorrect and I&#39;ve been trying to get it fixed but it hasn&#39;t happened yet.  If you can send a screen shot of your IntelliSense error to me (tdykstra at microsoft dot com) I&#39;ll look into it.  </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Drawer</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 05 Jul 2011 14:50:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013700</guid><description><![CDATA[ <p>I&#39;m using MS SQL Server 2008. When I tried to delete an instructor I got the error: The DELETE statement conflicted with the REFERENCE constraint &quot;Department_Administrator&quot;. The conflict occurred in database &quot;MvcContosoUniversity&quot;, table &quot;dbo.Department&quot;, column &#39;PersonID&#39;.</p><p>The statement has been terminated.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Drawer.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 06 Jul 2011 17:29:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013706</guid><description><![CDATA[ <p>@Drawer - That error means you assigned a instructor as administrator of a department and then tried to delete the instructor. You will have to assign a different instructor to the department first, then you can delete the instructor.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Drawer</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 07 Jul 2011 03:42:21 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013709</guid><description><![CDATA[ <p>Thanks, tdykstra. I understand the error, but I don&#39;t know how to fix it. Demaprtment.PersonID can be null, so I thought EF would automatically create a Delete Rule = &quot;Set Null&quot; for the &quot;Department_Administrator&quot; constraint, but it didn&#39;t. How to set Update/Delete rules in context OnModelCreating method?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Drawer.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 08 Jul 2011 20:55:33 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013734</guid><description><![CDATA[ <p>@Drawer - See this StackOverflow question:  <a rel="nofollow" href="http://stackoverflow.com/questions/5048561/entity-framework-set-delete-rule-with-codefirst" target="_blank">stackoverflow.com/</a></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Drawer</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 09 Jul 2011 05:30:12 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013736</guid><description><![CDATA[ <p>@tdykstra - thank you!</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Drawer.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by czechdude</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 14 Jul 2011 07:39:01 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013760</guid><description><![CDATA[ <p>the link to download the application leads to web forms version!</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/czechdude.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mrbelk</title><link>http://asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 14 Jul 2011 15:55:25 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013761</guid><description><![CDATA[ <p>Why doesn&#39;t the date format validation on the hire date work?  Also, how come we can&#39;t use &quot;ModelState.IsValid&quot; in the HTTP POST Edit method?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/mrbelk.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 18 Jul 2011 15:06:22 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013779</guid><description><![CDATA[ <p>@mrbelk - This is a bug in the code which I will fix in the tutorial. Add &quot;, Instructor instructor&quot; to the end of the parameter list for the Edit method, and then enclose the try/catch block in an &quot;If (ModelState.IsValid)&quot; statement.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&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/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 18 Jul 2011 16:29:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013781</guid><description><![CDATA[ <p>@mrbelk - Or a better solution: don&#39;t add an Instructor parameter to the method signature, just wrap the try/catch block in </p><p>if (TryUpdateModel(instructorToUpdate, &quot;&quot;, null, new string[] { &quot;Courses&quot; }))</p><p>And omit the UpdateModel from inside the try/catch block.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072735400000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>