I have some models and I want to have a "One to zero or one" association. I searched and tried to make the association using Fluent API. Here are my classes :
public partial class Bill
{
[Key]
public int Id { get; set; }
[Required]
public double Amount { get; set; }
public virtual DomainRegOrder DomainRegOrder { get; set; }
}
public partial class DomainRegOrder
{
[Key]
public int Id { get; set; }
[Required]
public string DomainName { get; set; }
public virtual Bill Bill { get; set; }
}
在我的数据信息类中:
public class DataContext : DbContext {
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<DomainRegOrder>()
.HasOptional(x => x.Bill)
.WithOptionalDependent();
}
but when I Initialize the Database, in the Bills table, I will have two columns named "DomainRegOrder_Id" and "DomainRegOrder_Id1".
我试图在 " 强 " 比尔 " /强 " 实体中添加 " 强 " 目标 " /强 ",作为铃声:
public int? DomainRegOrderId { get; set; }
但是,在“传单”的表格上将有一个“强”的“主页/强”和“强”的“强”的“主页/强”。
I also changed .WithOptionalDependent() to .WithOptionalPrincipal() but no changes were made as far as I know!!
有人能帮我弄掉这些 复制的外国钥匙吗?