Mapping a foreign key with a custom column name

前端 未结 3 1752
情书的邮戳
情书的邮戳 2020-12-05 03:51

I\'m using Entity Framework 4.3 code-first with Oracle. I\'m getting the following error:

System.InvalidOperationException : The ForeignKeyAttribute o

3条回答
  •  情歌与酒
    2020-12-05 04:41

    There is a table called Users and it has a primary key called UserID.

    There is another table called Directory, and it has a column called UserID which is defined as a foreign key to the Users table.

    I'm able to use the ForeignKey annotation to map the foreign key like this:

    [ForeignKey("xyzzy")]
    public int? UserID { get; set; }  // This is a column in the table
    public virtual User xyzzy { get; set; } // This is my instance of User
    

提交回复
热议问题