EF Code First CTP5 - Using the name of the property as column name for foreign key

后端 未结 2 720
渐次进展
渐次进展 2021-01-06 08:12

Given the following model:

public class Foo
{
    public int Id { get; set;}
    public Bar TheBar { get; set; }
}

public class Bar
{
    public int Id { ge         


        
相关标签:
2条回答
  • 2021-01-06 08:59

    The error was caused by a bug in CTP5. If the Id property was defined in a base class (which is not shown in the code above because I didn't think it was related), it breaks.

    I solved it by defining a base interface, but keeping the Id in each class.

    0 讨论(0)
  • 2021-01-06 09:04

    You want the MapKey method in the fluent interface.

    Alternately, if you do this throughout your model, CTP 5 has pluggable conventions, although this is, AFAIK, not well-documented yet.

    0 讨论(0)
提交回复
热议问题