У меня есть эта проблема:
имеет два объекта с отношением один к одному, загрузка их имеет одинаковое имя столбца Id
Document_head sales_Order
+-----------------+ +------------------+
+ DocumentId + + DocumentId +
+ Person + 1-----1 + OrderDate +
+ Status + + Purchaser +
+ ... + + ... +
+ ----------------+ +------------------+
Вот определение сущности
public partial class Document_head
{
public Document_head()
{
// Other
}
[Key]
public string DocumentId {get;set;}
public int PersonId {get;set;}
public int status {get;set;}
[ForeignKey("DocumentId")]
public virtual sales_Order sales_Order { get; set; }
}
public partial class sales_order
{
public sales_order()
{
//Other
}
[Key]
public string DocumentId { get; set; }
public virtual Document_head Document_head { get; set; }
}
Вот контекст
public class MyContext : DbContext
{
public DbSet Document_head Document_head{ get; set; }
public DbSet<sales_order> sales_order{ get; set; }
modelBuilder.Entity<Document_head>()
.HasOptional(p => p.sales_order).WithRequired();
modelBuilder.Entity<sales_order>()
.HasRequired(p => p.Document_head).WithOptional();
}
Проблема заключается в запуске приложения MVC3.
там сказано:
Имя столбца "Document_Head_DocumentId" недопустимо.
Я трачу много времени на эту ситуацию, если кто-то можетпомогите мне с этим .. будет очень признателен.