Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity framework code-first ignores table mapping
    primarykey
    data
    text
    <p>We have a ef project using an existing legacy database, but adding new tables to it using ef-migrations. For these entities, we create tables using a new schema, to separate them from the legacy tables. We use the convention with plural form of the class name on the db tables. However, when we add a new class to be mapped to a legacy table (without a plural table name), ef seems to ignore the mapping. The entity class:</p> <pre><code>public class Aktor:IVersionedEntityWithId { public int Id { get; set; } public string Navn { get; set; } public byte[] Version { get; set; } } </code></pre> <p>The mapping code:</p> <pre><code> protected virtual void MapAktor(EntityTypeConfiguration&lt;Tilsyn.Domain.Aktor&gt; config){ config.ToTable("dbo.Aktor"); config.Property(v=&gt;v.Version).IsConcurrencyToken().IsRowVersion(); config.HasKey(e=&gt;e.Id); } </code></pre> <p>The exception:</p> <blockquote> <p>System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid object name 'dbo.Aktors'.</p> </blockquote> <p>It seems like the sql generated still ad an s to the class name to get the table name. What is missing in this picture? Am I using the <code>ToTable</code> method wrong?</p> <p>Update: When changing the class name to something other than the table name, it seems to work. When changing the name back again, the problem has vansihed. Is there a EF cache or hidden mapping file somwehere? </p>
    singulars
    1. This table or related slice is empty.
    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.
    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