1
我們首先更新我們的數據庫,並有3個表:實體框架(6.1.3)如何命名ICollections?
Zoo_Keeper
Zoo_Mammal
Zoo_Reptile
(名稱變更爲簡單起見!)
門將可以有許多哺乳動物。
守護者可以有許多爬行動物。
Zoo_Mammal上的外鍵鏈接到Zoo_Keeper。
Zoo_Reptile上的外鍵鏈接到Zoo_Keeper。
在我們的EntityFramework使用「從數據庫更新模式」功能,以及生成的類我們Zoo_Keeper汽車看起來是這樣的:
namespace ZooApp.DataAccess.EntityDataModels
{
using System;
using System.Collections.Generic;
public partial class Zoo_Keeper
{
public Zoo_Keeper()
{
this.Mammals = new HashSet<Zoo_Mammal>();
this.Zoo_Reptile = new HashSet<Zoo_Reptile>();
}
//some properties
public virtual ICollection<Zoo_Mammal> Mammals { get; set; }
public virtual ICollection<Zoo_Reptile> Zoo_Reptile { get; set; }
}
}
如何EF想出了ICollections的名字? (Mammals,Zoo_Reptile)
我們很疑惑爲什麼一個人已經剝離了'Zoo'前綴,但另一個卻沒有。我們的數據庫是什麼導致EF命名關係不同?
我們已經檢查了FK的名字,但這些看起來都一致:
FK_Zoo_Mammal_Zoo_Keeper
FK_Zoo_Reptile_Zoo_Keeper
表中列的名稱是什麼? –
KeeperID,MammalID,ReptileID(PKs),KeeperID,KeeperID(FKs) – FBryant87