Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:27:11+00:00 2026-05-26T12:27:11+00:00

I am using MySQL .net connector 6.4.4.0 and Entity Frame work 4.1 and trying

  • 0

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.

public class myDB: DbContext
{
    public DbSet<Vote> Votes { get; set; }
}

my model

public class Vote
{
    public Guid Id { get; set; }
    public int Value { get; set; }
}

my home controller

public class HomeController : Controller
{
    myDB_db = new myDB();
    public ActionResult Index()
    {
        var model = _db.Votes;
        return View(model);
    }
}

my strongly typed view (using List scaffold)

@model IEnumerable<Namespace.Models.Vote>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Value)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Value)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
    }

</table>

It creates the table ‘votes’ in mySQL with all the right properties.

However, it throws at this line:

@foreach (var item in Model)

with the exception:

“Table ‘mydb.vote’ doesn’t exist”

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.

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

protected void Application_Start()
{
     Database.SetInitializer(new DropCreateDatabaseAlways<myDB>());

     AreaRegistration.RegisterAllAreas();
     RegisterGlobalFilters(GlobalFilters.Filters);
     RegisterRoutes(RouteTable.Routes);
}

public class myDBInitializer : DropCreateDatabaseAlways<myDB>
{
    protected override void Seed(myDBcontext)
    {
        base.Seed(context);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:27:12+00:00Added an answer on May 26, 2026 at 12:27 pm

    So I gave up on trying to do it the way I felt it should be done and removed pluralization all together. I don’t really know for certain, but I assume the problem has to do with the mysql .net connector’s support of EF. Here is what I did.

    First, there was a bug in my ApplicationStart method:

    //WRONG
    //Database.SetInitializer(new DropCreateDatabaseAlways<myDB>());
    Database.SetInitializer(new myDBInitializer());
    

    Second, I stopped calling the OnModelCreating base implementation which is not listed in the original code since I only implemented it as per jgauffin’s suggestion:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //DONT DO THIS ANYMORE
        //base.OnModelCreating(modelBuilder);
        //modelBuilder.Entity<Vote>().ToTable("Votes")
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
    }
    

    Third, I read in some posts that the MySQL .net Connector doesn’t let EF actually CREATE a database, so I had initially created the blank DB. This seems to no longer be the case with connector 6.4.4+, and as long as your connection string’s user has the ability to create new databases, it works better if one is not existing initially.

    Once, I did all of the above, it seemed to work. So now I can at least move forward. Hopefully we can figure out the cause of the plural / singular discrepancy in the future.

    Thanks to everyone for their time and effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
long-time listener, first-time caller! I’m trying to connect to MySQL using the ADO.NET Entity
I am trying to generate my ADO.NET entity model from my MySQL database using
Using Windows Server 2003, MySQL 5.1.23, MySQL .NET Connector 6.2.2 I am trying to
I'm using MySql Connector .NET to load an account and transfer it to the
I am using MySQL with the .Net connector on 64 bit Windows. For some
I'm a beginner at this. I'm using mysql connector .net to connect vb.net with
I'm trying to extract a date field from a mysql db using .NET and
I'm using the MySql connector for .NET to copy data from MySql servers to
I'm using ASP.NET MVC. I'm also using the MySQL connector and providers to connect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.