0

Given the following entity:

    public partial class InstructorPartition
    {
        [Key]
        [Column(Order = 0)]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int FkInstructorId { get; set; }

        [Key]
        [Column(Order = 1)]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int PartitionId { get; set; }
    }

EF 6.1.3 is generating an additional column in queries, which doesn't exist (and causing errors in SQL)

dc.InstructorPartitions
{SELECT 
[Extent1].[FkInstructorId] AS [FkInstructorId], 
[Extent1].[PartitionId] AS [PartitionId], 
[Extent1].[Instructor_InstructorId] AS [Instructor_InstructorId]
FROM [dbo].[InstructorPartitions] AS [Extent1]}
base: {SELECT 
[Extent1].[FkInstructorId] AS [FkInstructorId], 
[Extent1].[PartitionId] AS [PartitionId], 
[Extent1].[Instructor_InstructorId] AS [Instructor_InstructorId]
FROM [dbo].[InstructorPartitions] AS [Extent1]}
Local: Count = 0

Why is EF generating the "Instructor_InstructorId" column reference (which doesnt exist)?

Expected query wouldn't include the Instructor_InstructorId

Also, looked through OnModelCreating to make sure nothing "added" to InstructorPartition entity.

enorl76
  • 2,562
  • 1
  • 25
  • 38
  • 1
    It looks like this is probably due to a foreign key issue. This question looks like a similar issue: http://stackoverflow.com/questions/10909061/why-am-i-getting-an-extra-foreign-key-column-with-entity-framework-code-first-fo – DHP May 31 '16 at 17:06
  • Your class is partial may you forgot about another part of it declaration? – Slava Utesinov Jun 01 '16 at 06:33
  • @DHP you were correct. add that as an answer and i'll mark it answered – enorl76 Jun 01 '16 at 16:29

0 Answers0