EF6 Code First Pluralizing Tables Invalid Object Name

ef-code-first entity-framework entity-framework-6

Question

No matter what I do, EF6 always pluralizes the names of my Code First tables. I keep getting the message "Invalid object name 'dbo.TestStats'." when trying to locate the pluralized table. The table is identified in the database as dbo, which is singular. TestStat

I made an effort to do so by

protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

Additionally, I mapped it to the name of a single table.

    public TestStatMap()
    {
        // Primary Key
        this.HasKey(t => t.TestStatId);

        this.ToTable("TestStat");

Even so, I attempted to add this to the OnModelCreating override.

modelBuilder.Entity<TestStat>().ToTable("TestStat");

Here is the table that the EF power tools produced and to which I am attempting to map it. What am I missing or what else can I try?

CREATE TABLE [dbo].[TestStat] (
[TestStatId] [int] NOT NULL IDENTITY,
[SeasonID] [int],
[TeamID] [int],
CONSTRAINT [PK_dbo.TestStat] PRIMARY KEY ([TestStatId])

)

1
3
12/8/2013 6:26:24 PM

Accepted Answer

ZZZ_tmp
1
12/13/2013 2:42:15 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow