<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>Implementing Inheritance with the Entity Framework in an ASP.NET MVC Application (8 of 10)</title><link>http://www.asp.net</link><pubDate>Wed, 03 Oct 2012 13:03:35 GMT</pubDate><generator>umbraco</generator><description>Comments for Implementing Inheritance with the Entity Framework in an ASP.NET MVC Application (8 of 10)</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/33315" rel="self" type="application/rss+xml" /><item><title>Comment Posted by timheff</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 09 May 2011 13:55:15 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013111</guid><description><![CDATA[ <p>There seems to be a problem in the Instructor Index.cshtml after implementing these changes and attempting to test.  I get the &quot;There is already an open DataReader associated with this Command which must be closed first.&quot; error in the view at this line...</p><p>                @if (item.OfficeAssignment != null) </p><p>I downloaded the completed application to verify that the same error occurs with that solution and it does.</p><p>                </p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/timheff.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by timheff</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 09 May 2011 15:30:12 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013113</guid><description><![CDATA[ <p>I found I just had to add &#39;MultipeActiveResultSets=true&#39; to my connection string.  I&#39;m using SQL Server Developer Edition on my machine.  For anyone else who might have the same scenario (not using SQL Server Compact), here is my full connection string...&lt;add name=&quot;SchoolContext&quot; connectionString=&quot;Data Source=localhost;Initial Catalog=ContosoUniversity; Integrated Security=SSPI; MultipleActiveResultSets=True &quot;  providerName=&quot;System.Data.SqlClient&quot;/&gt;</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/timheff.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by pseudo70</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 20 May 2011 13:22:38 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013231</guid><description><![CDATA[ <p>Your advice &quot;In Instructor.cs, derive the Instructor class from the Person class, change the InstructorID property to PersonID, and remove the key and name fields. The code will look like the following example:&quot; reflects not the given example code. There is no PersonID in this example code. Should Instructor.cs now contain the PersonID foreign key or not? The same for the Person.cs class.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/pseudo70.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by pseudo70</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 20 May 2011 13:27:48 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013232</guid><description><![CDATA[ <p>I mean, the same for the Student.cs class. Not Person.cs class.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/pseudo70.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sun, 22 May 2011 11:14:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013244</guid><description><![CDATA[ <p>@pseudo70 - You are correct, thanks for pointing that out. I will remove the phrase &quot;change the InstructorID property to PersonID&quot;.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by obdense</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 03 Jun 2011 17:18:50 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013384</guid><description><![CDATA[ <p>timheff - Thank you for your postings. I encountered the exact issue using SQL Server Express Edition 10.50.1600.1. I added the MultipleActiveResultSets=true and all was well.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/obdense.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by dreamscourge</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 16 Jun 2011 12:26:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013543</guid><description><![CDATA[ <p>@timheff Thanks again, had the same problem too. SQL Server 2008 R2</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/dreamscourge.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by chicachan</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 30 Jun 2011 22:07:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013648</guid><description><![CDATA[ <p>How can I &quot;Next, perform a global change (all files in the project) to change InstructorID to PersonID&quot;,Please explain its detail? thank you.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/chicachan.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 04 Jul 2011 14:50:28 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013686</guid><description><![CDATA[ <p>@chicachan - Type control/h to get the change dialog in Visual Studio, and you&#39;ll see that one of the options is to make the specified change in all files.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by hong6</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 04 Jul 2011 21:43:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013691</guid><description><![CDATA[ <p>great Tutorial!</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/hong6.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 23 Sep 2011 17:28:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014254</guid><description><![CDATA[ <p>What was the specific act we did in this tutorial that signalled to the Entity Framework the need to add the &quot;Discriminator&quot; column to our [Person] table.  Was it the mere change of inheriting from Person.cs? Like when [Instructor] and [Student] tacked on the inheritance clause of &quot; : Person&quot; to the &quot;public class Instructor : Person&quot; and &quot;public class Student : Person&quot; statements?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 06 Oct 2011 14:44:49 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014343</guid><description><![CDATA[ <p>@TheGDizzo - Yes, that is all EF needs to determine that it needs a discriminator column.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by TekzMekz</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Sat, 08 Oct 2011 17:17:40 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014370</guid><description><![CDATA[ <p>Please help!!!  I manually followed all the steps since I do not want to implement the last two tutorials, so I don&#39;t want to work backwards from the downloadable full demo. It would be great if a download point was made available at the end of every tutorial. Anyway... I had everything  until I got to the step where you instruct us to do the following:</p><p></p><p>&quot;Next, perform a global change (all files in the project) to change InstructorID to PersonID and StudentID to PersonID. Make sure that this change is case-sensitive.&quot;</p><p></p><p>Now I cannot access the Instructors page. It stops in the line:</p><p>&quot;@foreach (var item in Model.Instructors) {&quot; </p><p>with the following error:</p><p></p><p>&quot;The ResultType of the specified expression is not compatible with the required type. The expression ResultType is &#39;Transient.reference[ContosoUniversity.Models.Person]&#39; but the required type is &#39;Transient.reference[ContosoUniversity.Models.Instructor]&quot; </p><p></p><p>Thanks for an excellent tutorial.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TekzMekz.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 19 Oct 2011 22:09:32 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014461</guid><description><![CDATA[ <p>@TekzMekz - Double-check the changes in the entities themselves, this does not sound like a problem with renaming the ID fields.  Althought the download project has other changes in it, you can still compare most of the files, such as the entity classes to see what you might have missed.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by websmith</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 08 Mar 2012 16:20:36 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015067</guid><description><![CDATA[ <p>I, too, am having the problem with the Datareader.  However, the change suggested does not fix it for me.  So what is causing this error to happen in the first place?  It happens, as mentioned, when hitting:</p><p></p><p>@if(item.OfficeAssignment != null)</p><p></p><p>In the Instructors\Index.cshtml view. </p><p></p><p>Any other suggestions?  My database is on SQL Server 8.00.2055</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/websmith.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 09 Mar 2012 15:06:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015080</guid><description><![CDATA[ <p>@websmith - I recommend submitting that to the ASP.NET forum or to StackOverflow.com.  For the next release of the tutorial we may add a sidebar about changes needed for other versions of SQL Server; if you find a solution and post it here we&#39;ll make sure it gets added to the tutorial.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by redcolin</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Thu, 12 Apr 2012 12:09:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015305</guid><description><![CDATA[ <p>@websmith - there is a typo in timheff&#39;s op - &quot;Multiple&quot; had the second &quot;L&quot; missing - perhaps this will solve your issue as it did for me.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/redcolin.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mjeson</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 07 May 2012 20:47:50 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015466</guid><description><![CDATA[ <p>This TPH-over-TPT recommendation makes me cautious to apply MVC in data intensive production environment.</p><p></p><p>I come from Oracle where dealing with 100 millions of records with hundreds columns is a performance hell unleashed. Index stops working since every query is a full-table-scan due to large data retrieval. TPT is a way to divide this huge dataset into smaller records with less columns.</p><p></p><p>Ideally speaking, MVC should only be dependent upon the actual size of dataset, regardless of TPH/TPT.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/mjeson.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jsiahaan</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 15 May 2012 21:18:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015514</guid><description><![CDATA[ <p>@websmith - Has the problem with &quot;@if(item.OfficeAssignment != null) In the Instructors\Index.cshtml view&quot; been solved?</p><p>I have the same problem too using ASP.NET MVC 4 Beta version, Ef 5.0 pre release,  VS 2010, SQL Server 2012 Express Edition on Windows Server 2008 R2. The only problem I have is the same with you.</p><p>I also tried several time using ASP.NET MVC 4 beta, VS 11 Beta, EF 4.1 and EF 4.3 and EF 5.0, Win 8 Consumer preview and I can not create all Controllers but only CourseController</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/jsiahaan.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by spacemishka</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 22 Jun 2012 07:54:51 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015822</guid><description><![CDATA[ <p>I am getting a parsererror when i try to run my App after the changes of this part.</p><p></p><p>Line 1:  &lt;%@ Application Codebehind=&quot;Global.asax.cs&quot; Inherits=&quot;ContosoUniversity.MvcApplication&quot; Language=&quot;C#&quot; %&gt;</p><p></p><p>Whats wrong?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/spacemishka.jpg?forceidenticon=false&amp;dt=635072587200000000&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/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Fri, 22 Jun 2012 17:40:48 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015826</guid><description><![CDATA[ <p>@spacemishka - The easiest way to troubleshoot is to download the completed application, then compare the code there with what you created by following the tutorial. You might have mistyped something or omitted a step.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/tdykstra.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Takumi</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 03 Jul 2012 10:22:44 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015899</guid><description><![CDATA[ <p>@jsiahaan, @websmith</p><p>I have the same problem and found an answer in this thread: <a rel="nofollow" href="http://social.msdn.microsoft.com/Forums/de/visualcsharpde/thread/e2c548b2-98e2-4cb4-a2e2-1ff164a0d2b1" target="_blank">social.msdn.microsoft.com/</a></p><p></p><p>After adding MultipleActiveResultSets=True; to the connection string the problem is solved. This may lead to other problems, but for now it&#39;s working. :-)</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Takumi.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mudasir.khan</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Mon, 16 Jul 2012 13:40:33 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015986</guid><description><![CDATA[ <p>SuperB, Thanks for such a nice and excellent way of explanation</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/mudasir.khan.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by aaronnewton</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Tue, 18 Sep 2012 08:59:29 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016454</guid><description><![CDATA[ <p>If you are getting the &quot;There is already an open DataReader &quot; error, please take a look at <a rel="nofollow" href="http://stackoverflow.com/a/7928157/201648." target="_blank">stackoverflow.com/</a></p><p></p><p>For InstructorController.cs I added .ToList() like so:</p><p></p><p>            viewModel.Instructors = db.Instructors</p><p>                .Include(i =&gt; i.Courses.Select(c =&gt; c.Department))</p><p>                .ToList()</p><p>                .OrderBy(i =&gt; i.LastName);</p><p></p><p>Do this anywhere we deleted &#39;.Include(i =&gt; i.OfficeAssignment)&#39;. This appears to have fixed the problem.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/aaronnewton.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gagouche</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application</link><pubDate>Wed, 03 Oct 2012 13:03:35 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016569</guid><description><![CDATA[ <p>I am a little confused here. You explained the difference between TPH and TPT. Since you are going to use TPH, I expected the instructor and student class to be completely gone.  Instead they inherited the base class. Isn&#39;t that still TPT, or were you only referring to the database and not the actuall class design?</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/gagouche.jpg?forceidenticon=false&amp;dt=635072587200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>