我有下圖中的 2 個表,想在它們之間添加外鍵關系,其中 ServiceID 是外鍵
我的 2 個表并排 我的資料庫背景關系
uj5u.com熱心網友回復:
將以下內容添加到 ServiceStatistics:
[ForeignKey("ServiceLogRefId")]
public ServiceLog ServiceLog {get; set; }
public int ServiceLogRefId {get; set; }
給定版本的注釋可能略有不同(您沒有在問題中指定)。
uj5u.com熱心網友回復:
你的代碼可以是這樣的:
public class LoginLog
{
.
.
.
public int ServiceStateId{ get; set; }
public ServiceState ServiceState{ get; set; }
}
public class ServiceState
{
.
.
.
public ICollection<LoginLog> LoginLogs{ get; set; }
}
您還可以在此鏈接中獲得有關關系的所有資訊:EF 中的關系
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/361367.html
上一篇:完美正方形Python
下一篇:非平凡依賴的推導
