title: EF Code First "Invalid column name 'Discriminator'" but no inheritance
body: <p>I have a table in my database called SEntries (see below the CREATE TABLE statement). It has a primary key, a couple of foreign keys and nothing special about it. I have many tables in my database similar to that one, but for some reason, this table ended up with a "Discriminator" column on the EF Proxy Class.</p>
  
  <p>This is how the class is declared in C#:</p>
  
  <pre><code>public class SEntry
  {
      public long SEntryId { get; set; }
  
      public long OriginatorId { get; set; }
      public DateTime DatePosted { get; set; }
      public string Message { get; set; }
      public byte DataEntrySource { get; set; }
      public string SourceLink { get; set; }
      public int SourceAppId { get; set; }
      public int? LocationId { get; set; }
      public long? ActivityId { get; set; }
      public short OriginatorObjectTypeId { get; set; }
  }
  
  public class EMData : DbContext
  {
      public DbSet&lt;SEntry&gt; SEntries { get; set; }
              ...
      }
  </code></pre>
  
  <p>When I try to add a new row to that table, I get the error:</p>
  
  <pre><code>System.Data.SqlClient.SqlException: Invalid column name 'Discriminator'.
  </code></pre>
  
  <p>This problem only occurs if you are inheriting your C# class from another class, but SEntry is not inheriting from anything (as you can see above).</p>
  
  <p>In addition to that, once I get the tool-tip on the debugger when I mouse over the EMData instance for the SEntries property, it displays:</p>
  
  <pre><code>base {System.Data.Entity.Infrastructure.DbQuery&lt;EM.SEntry&gt;} = {SELECT 
  [Extent1].[Discriminator] AS [Discriminator], 
  [Extent1].[SEntryId] AS [SEntryId], 
  [Extent1].[OriginatorId] AS [OriginatorId], 
  [Extent1].[DatePosted] AS [DatePosted], 
  [Extent1].[Message] AS [Message], 
  [Extent1].[DataEntrySource] AS [DataE...
  </code></pre>
  
  <p>Any suggestions or ideas where to get to the bottom of this issue? I tried renaming the table, the primary key and a few other things, but nothing works.</p>
  
  <p>SQL-Table:</p>
  
  <pre><code>CREATE TABLE [dbo].[SEntries](
  [SEntryId] [bigint] IDENTITY(1125899906842624,1) NOT NULL,
  [OriginatorId] [bigint] NOT NULL,
  [DatePosted] [datetime] NOT NULL,
  [Message] [nvarchar](500) NOT NULL,
  [DataEntrySource] [tinyint] NOT NULL,
  [SourceLink] [nvarchar](100) NULL,
  [SourceAppId] [int] NOT NULL,
  [LocationId] [int] NULL,
  [ActivityId] [bigint] NULL,
  [OriginatorObjectTypeId] [smallint] NOT NULL,
  CONSTRAINT [PK_SEntries] PRIMARY KEY CLUSTERED 
  (
  [SEntryId] ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,       ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  
  GO
  
  ALTER TABLE [dbo].[SEntries]  WITH CHECK ADD  CONSTRAINT [FK_SEntries_ObjectTypes] FOREIGN KEY([OriginatorObjectTypeId])
  REFERENCES [dbo].[ObjectTypes] ([ObjectTypeId])
  GO
  
  ALTER TABLE [dbo].[SEntries] CHECK CONSTRAINT [FK_SEntries_ObjectTypes]
  GO
  
  ALTER TABLE [dbo].[SEntries]  WITH CHECK ADD  CONSTRAINT [FK_SEntries_SourceApps] FOREIGN KEY([SourceAppId])
  REFERENCES [dbo].[SourceApps] ([SourceAppId])
  GO
  
  ALTER TABLE [dbo].[SEntries] CHECK CONSTRAINT [FK_SEntries_SourceApps]
  GO
  </code></pre>