是否可以使用内部访问声明 Code First 数据类,如下所示:
internal class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个要求,类及其属性不应在程序集外部可见。
当两个表之间存在链接(连接)表时,我有一个关于两个表之间的一对多关系的问题.
示例表:
ChildTable:
ID int NOT NULL PK
Relation int NOT NULL
ParentTable:
ID int NOT NULL PK
Name nvarchar(50) NOT NULL
ParentChildren:
ParentTable_ID int NOT NULL PFK
ChildTable_ID int NOT NULL PFK
Run Code Online (Sandbox Code Playgroud)
实体:
public class ChildTable
{
public ChildTable()
{
this.ParentTables = new List<ParentTable>();
}
public int ID { get; set; }
public int Relation { get; set; }
public virtual ICollection<ParentTable> ParentTables { get; set; }
}
public class ParentTable
{
public ParentTable()
{
this.ChildTables = new List<ChildTable>(); …Run Code Online (Sandbox Code Playgroud)