Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework creates a plural table name, but the view expects a singular table name?
    primarykey
    data
    text
    <p>I am using MySQL .net connector 6.4.4.0 and Entity Frame work 4.1 and trying to create the most basic of code-first implementations.</p> <pre><code>public class myDB: DbContext { public DbSet&lt;Vote&gt; Votes { get; set; } } </code></pre> <p>my model</p> <pre><code>public class Vote { public Guid Id { get; set; } public int Value { get; set; } } </code></pre> <p>my home controller</p> <pre><code>public class HomeController : Controller { myDB_db = new myDB(); public ActionResult Index() { var model = _db.Votes; return View(model); } } </code></pre> <p>my strongly typed view (using List scaffold)</p> <pre><code>@model IEnumerable&lt;Namespace.Models.Vote&gt; @{ ViewBag.Title = "Index"; } &lt;h2&gt;Index&lt;/h2&gt; &lt;p&gt; @Html.ActionLink("Create New", "Create") &lt;/p&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.Value) &lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.Value) &lt;/td&gt; &lt;td&gt; @Html.ActionLink("Edit", "Edit", new { id=item.Id }) | @Html.ActionLink("Details", "Details", new { id=item.Id }) | @Html.ActionLink("Delete", "Delete", new { id=item.Id }) &lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </code></pre> <p>It creates the table 'votes' in mySQL with all the right properties.</p> <p>However, it throws at this line:</p> <p>@foreach (var item in Model)</p> <p>with the exception:</p> <p><strong>"Table 'mydb.vote' doesn't exist"</strong></p> <p>edit: To clarify, I actually want table pluralization, and it seems to properly create the table. I'm hoping to discover the reason for the singular/plural discrepancy. None of the tutorials and videos from microsoft / Plural Sight / scott gu handle using mysql, so i have to imagine that the .netconnector might be the culprit. I would also like to avoid using the [Table("Votes")] attributes. Basically I'm hoping for as much of an 'out of the box' solution as possible.</p> <p>edit2 (some more relevant code): when i remove this...tables fail to create all together. but the view throws an exception looking for 'votes' not 'vote'. within global.asax</p> <pre><code>protected void Application_Start() { Database.SetInitializer(new DropCreateDatabaseAlways&lt;myDB&gt;()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); } public class myDBInitializer : DropCreateDatabaseAlways&lt;myDB&gt; { protected override void Seed(myDBcontext) { base.Seed(context); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload