EntityFramework : Invalid column name *_ID1

c#-4.0 entity-framework-6

Accepted Answer

Hello, after investing some time, I was able to useForeignKey on attributepublic virtual Department Department { get; set; } possession ofEmployee class.

See the code below.

 [Table("Employee")]
public class Employee
{
    [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [Column("Name")]
    public string Name { get; set; }

    [Column("Department_ID")]        
    public int Department_ID { get; set; }

    [ForeignKey("Department_ID")]
    public virtual Department Department { get; set; }
}

This solved my issue. Exists an other fix for this? fluent API being used?

12
6/3/2016 5:45:52 AM

Popular Answer

ZZZ_tmp


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