<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>Adding a New Field to the Movie Model and Table</title><link>http://www.asp.net</link><pubDate>Wed, 22 Feb 2012 16:10:20 GMT</pubDate><generator>umbraco</generator><description>Comments for Adding a New Field to the Movie Model and Table</description><language>en</language><atom:link href="http://www.asp.net/rss/comments/27655" rel="self" type="application/rss+xml" /><item><title>Comment Posted by benhayat</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 19 Jan 2011 09:19:31 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011637</guid><description><![CDATA[ <p>@Ricka;</p><p>Thanks for the info. Found your blog and the subsequent blogs on the MVC v.s. WebForm. Now decision time... :-)</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/benhayat.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by nuri</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Thu, 14 Apr 2011 03:07:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012801</guid><description><![CDATA[ <p>Typo: using System.Data.Entity.Database;  // Database.SetInitialize</p><p></p><p>should be :</p><p></p><p>using System.Data.Entity;  // Database.SetInitialize</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/nuri.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ricka6</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Sat, 16 Apr 2011 16:21:31 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012840</guid><description><![CDATA[ <p>nuri : Thanks for reporting this. It&#39;s fixed now.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ricka6.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ms_michel</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Thu, 21 Apr 2011 09:00:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012915</guid><description><![CDATA[ <p>The &#171;th&#187;&#171;/th&#187; in Index.cshtml view template should not be before &#171;th&#187;Title&#171;/th&#187; but after &#171;th&#187;Rating&#171;/th&#187;. With this correction, the last two screenshots for movie list will have a correct header. Currently there is a shift of one column.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ms_michel.jpg?forceidenticon=false&amp;dt=635051239200000000&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-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Sun, 15 May 2011 12:55:08 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013175</guid><description><![CDATA[ <p>This doesn&#39;t work if I am using a database already up and running. </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Xequence.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by osm1987</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 31 May 2011 17:14:09 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013347</guid><description><![CDATA[ <p>Could you please provide me with a tutorial for the second approach to update the db scheme.</p><p></p><p>Please :)</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/osm1987.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by bug eliminator</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 01 Jun 2011 11:03:33 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013355</guid><description><![CDATA[ <p>I updated my DB manually and still getting the exception &quot;The model backing the &#39;MovieDBContext&#39; context has changed since the database was created...&quot;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/bug%20eliminator.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Adam C Anderson</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Mon, 13 Jun 2011 17:15:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013498</guid><description><![CDATA[ <p>After you manually update your DB, just drop the EdmMetadata table and the exception will cease.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Adam%20C%20Anderson.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by imhttran</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 22 Jun 2011 16:15:56 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013582</guid><description><![CDATA[ <p>your list title here may be a little off. </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/imhttran.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mohramzan</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Sat, 09 Jul 2011 12:40:34 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013737</guid><description><![CDATA[ <p>@Xequence, mate you need to close the open connection first and then build and run. </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/mohramzan.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by pallu</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Thu, 28 Jul 2011 13:10:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013864</guid><description><![CDATA[ <p>Wow, wouldn&#39;t it be dangerous to drop and create in a production environment? Wouldn&#39;t it be safer to make the necessary database schema update and have this in the MovieDbContext:</p><p></p><p>protected override void OnModelCreating(DbModelBuilder modelBuilder)</p><p>        {           </p><p>           modelBuilder.Conventions.Remove&lt;IncludeMetadataConvention&gt;();</p><p>        }</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/pallu.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ricka6</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Thu, 28 Jul 2011 17:22:28 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013870</guid><description><![CDATA[ <p>pallu: Yes, as noted in the article, drop/create is only for early development, not production. It make development much faster.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ricka6.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by thiagosatoshi</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Sat, 27 Aug 2011 14:09:51 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014063</guid><description><![CDATA[ <p>Hi.</p><p>I have one problem, when I insert 6.99 or 6,99 in the price and I try save I always receive this message: </p><p>&quot;The value &#39;6.99&#39; is not valid for Price.&quot; or &quot;The value &#39;6,99&#39; is not valid for Price.&quot; </p><p>How I can fix this?</p><p>Maybe this because my current language pr-br?</p><p></p><p>Thanks</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/thiagosatoshi.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by matt.g</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 30 Aug 2011 19:45:56 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014090</guid><description><![CDATA[ <p>Maybe development is faster by learning &quot;drop/create&quot;, but is learning this method of development really ill-advised, if you would never want to do this in a production environment? And wouldn&#39;t it make sense to include the instructions for the non-drop method? Thanks.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/matt.g.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mlowry</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 31 Aug 2011 07:08:40 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014092</guid><description><![CDATA[ <p>I agree with matt.g. Putting code into an application that drops the database on any change in schema is a really bad idea if you ever plan to work with production data. I would really appreciate adding the instructions to change the database without dropping it.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/mlowry.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jrichview</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 28 Sep 2011 14:14:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014294</guid><description><![CDATA[ <p>Chances are in a production database you won&#39;t be running a debug build.  There&#39;s probably some way to change what code builds depending whether it&#39;s a debug build or not.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/jrichview.jpg?forceidenticon=false&amp;dt=635051239200000000&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-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 18 Oct 2011 01:24:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014445</guid><description><![CDATA[ <p>The following two lines in your example need to be corrected:</p><p></p><p>(in Global.asax)</p><p>namespace MvcMovie.Models { </p><p>(should instead be)</p><p>namespace MvcMovies.Models {</p><p></p><p>(in MovieInitializer.cs</p><p>namespace MvcMovie.Models{</p><p>(should instead be)</p><p>namespace MvcMovies.Models{</p><p></p><p>Without this corrrection, when you attempt to run in Debug mode in the IDE it gives the error that:</p><p></p><p>The type or namespace &#39;MovieInitializer&#39; could not be found (are you missing a using directive or an assembly reference)</p><p>---AND---</p><p>The type or namespace &#39;MovieDBContext&#39; could not be found. (are you missing a using directive or an assembly reference)</p><p></p><p>Took me a minute or two to notice that subtle error. Figured I&#39;d call it to your attention.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635051239200000000&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-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 25 Oct 2011 15:33:27 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014495</guid><description><![CDATA[ <p>Whoops! My Apologies. I just noticed that apparently I&#39;d named my App &quot;MvcMovies&quot; from the beginning... whereas apparently in the lesson it&#39;s been named &quot;MvcMovie&quot;.  </p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by LynxCat</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Mon, 31 Oct 2011 14:46:15 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014527</guid><description><![CDATA[ <p>Dear Ricka6,</p><p>I have noticed a bug in the Movie App as it is written in the tutorial.  If you attempt to edit any of the movie listings, there is no textbox for the rating.  If you edit any field for a given movie, then the rating for that movie gets erased.</p><p></p><p>You may want to consider adding the following code in the tutorial for the Edit.cshtml and Details.cshtml files:</p><p>Edit.cshtml </p><p>    &lt;div class=&quot;editor-label&quot;&gt;</p><p>        @Html.LabelFor(model =&gt; model.Rating)</p><p>    &lt;/div&gt;</p><p>    &lt;div class=&quot;editor-field&quot;&gt;</p><p>        @Html.EditorFor(model =&gt; model.Rating)</p><p>        @Html.ValidationMessageFor(model =&gt; model.Rating)</p><p>    &lt;/div&gt;</p><p>Details.cshtml</p><p>    &lt;div class=&quot;display-label&quot;&gt;Rating&lt;/div&gt;</p><p>    &lt;div class=&quot;display-field&quot;&gt;</p><p>        @Html.DisplayFor(model =&gt; model.Rating)</p><p>    &lt;/div&gt;</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/LynxCat.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ferry2</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Thu, 10 Nov 2011 17:12:22 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014604</guid><description><![CDATA[ <p>If you have problems with dot or comma separator add this class to the project:</p><p></p><p>using System;</p><p>using System.Globalization;</p><p>using System.Web.Mvc;</p><p></p><p>namespace MvcМоvie</p><p>{</p><p>  public class CustomModelBinder : DefaultModelBinder {</p><p></p><p>    public CustomModelBinder()</p><p>      : base() {</p><p>    }</p><p></p><p>    public override object BindModel(ControllerContext controllerContext, </p><p>      ModelBindingContext bindingContext) {</p><p>      </p><p>      object result = null;</p><p></p><p>      // Don&#39;t do this here!</p><p>      // It might do bindingContext.ModelState.AddModelError</p><p>      // and there is no RemoveModelError!</p><p>      // </p><p>      // result = base.BindModel(controllerContext, bindingContext);</p><p></p><p>      if (bindingContext.ModelType == typeof(decimal)) {</p><p></p><p>        string modelName = bindingContext.ModelName;</p><p>        string attemptedValue = bindingContext.ValueProvider[modelName].AttemptedValue;</p><p></p><p>        // Depending on cultureinfo the NumberDecimalSeparator can be &quot;,&quot; or &quot;.&quot;</p><p>        // Both &quot;.&quot; and &quot;,&quot; should be accepted, but aren&#39;t.</p><p>        string wantedSeperator = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;</p><p>        string alternateSeperator = (wantedSeperator == &quot;,&quot; ? &quot;.&quot; : &quot;,&quot;);</p><p></p><p>        if (attemptedValue.IndexOf(wantedSeperator) == -1 </p><p>          &amp;&amp; attemptedValue.IndexOf(alternateSeperator) != -1) {</p><p>          attemptedValue = attemptedValue.Replace(alternateSeperator, wantedSeperator);</p><p>        }</p><p></p><p>        try {</p><p>          result = decimal.Parse(attemptedValue, NumberStyles.Any);</p><p>        }</p><p>        catch (FormatException e) {</p><p>          bindingContext.ModelState.AddModelError(modelName, e);</p><p>        }</p><p></p><p>      }</p><p>      else {</p><p>        result = base.BindModel(controllerContext, bindingContext);</p><p>      }</p><p></p><p>      return result;</p><p>    }</p><p>  }</p><p>}</p><p></p><p>and in the Global.asax.cs add:</p><p></p><p>protected void Application_Start()</p><p>{</p><p>     Database.SetInitializer&lt;MovieDBContext&gt;(new MovieInitializer());</p><p></p><p>     AreaRegistration.RegisterAllAreas();</p><p>     ModelBinders.Binders.DefaultBinder = new CustomModelBinder();</p><p>}</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ferry2.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by calibur</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 15 Nov 2011 11:44:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014631</guid><description><![CDATA[ <p>I am using SQLExpress and I am getting a error saying : Cannot drop MovieDB because it is currently in use.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/calibur.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by calibur</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Tue, 15 Nov 2011 11:48:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014632</guid><description><![CDATA[ <p>HI Ricka6</p><p></p><p>I am using a SQLExpress DB and I get an error message saying that the Database is in use when I run the app after implementing the code above.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/calibur.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Sergiy.Shumakov</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 16 Nov 2011 05:05:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014638</guid><description><![CDATA[ <p>Hi guys, the last picture where all movies are shown, isn&#39;t displayed correctly. (Genre column contains price values and Price column contains rating values).</p><p></p><p>I think it would be nice to fix it in order not to confuse newbies.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/Sergiy.Shumakov.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by basbak</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Mon, 28 Nov 2011 02:22:46 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014703</guid><description><![CDATA[ <p>In the Create.cshtml forms, does anyone know how to substitute the @Html.EditorFor(model =&gt; model.AnyName) with a statement that gets accepted by the Model as a valid input. </p><p>I have tried @Html.Encode to show the AnyName by exracting it from a db, but the Model.IsValid returns False.</p><p>Ny idea, anyone?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/basbak.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by postonoh</title><link>http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-new-field</link><pubDate>Wed, 22 Feb 2012 16:10:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014916</guid><description><![CDATA[ <p>Thanks this work great. Can you reference a website with the second way you posted.</p><p>You have listed as way two.  Explicitly modify the schema of the existing database so that it matches the model classes. The advantage of this approach is that you keep your data. You can make this change either manually or by creating a database change script.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/postonoh.jpg?forceidenticon=false&amp;dt=635051239200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>