リレーションシップと 2 つの ID 列を使用して保存する 2 つの個別のテーブルを取得できません。ReferentialConstraint の依存プロパティがストアで生成された列にマップされているなどのエラーが発生し続けます。列: 'OlsTerminalId'。この設定が異常だとは思えません。
[DataContract]
public class OlsData {
private static readonly DateTime theUnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int OlsDataId { get; set; }
[DataMember(Name = "id")]
public int Id { get; set; }
public DateTime Timestamp { get; set; }
[DataMember(Name = "created")]
[NotMapped]
public double Created {
get { return (Timestamp - theUnixEpoch).TotalMilliseconds; }
set { Timestamp = theUnixEpoch.AddMilliseconds(value); }
}
[InverseProperty("OlsData")]
[DataMember(Name = "terminal")]
public virtual OlsTerminal OlsTerminal { get; set; }
}
[DataContract]
public class OlsTerminal {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int OlsTerminalId { get; set; }
public int OlsDataId { get; set; }
[DataMember(Name = "account")]
[NotMapped]
public virtual OlsAccount OlsAccount { get; set; }
[DataMember(Name = "terminalId")]
public string TerminalId { get; set; }
[DataMember(Name = "merchantId")]
public string MerchantId { get; set; }
public virtual OlsData OlsData { get; set; }
}
public class OlsDataContext : DbContext {
protected override void OnModelCreating(DbModelBuilder aModelBuilder) {
aModelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
public OlsDataContext(string aConnectionString) : base(aConnectionString) {}
public DbSet<OlsData> OlsData { get; set; }
public DbSet<OlsTerminal> OlsTerminal { get; set; }
public DbSet<OlsAccount> OlsAccount { get; set; }
}