Mapping a foreign key with a custom column name

前端 未结 3 1756
情书的邮戳
情书的邮戳 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

    ForeignKey attibute expects a property name in your class as the argument but you given the column name. Use fluent mappings.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
    
        modelBuilder.Entity()
         .HasRequired(w => w.Sequence)
         .WithMany()
         .Map(m => m.MapKey("WIDGETSEQUENCE_ID"));
    }
    

提交回复
热议问题