小编Min*_*nie的帖子

实体框架代码优先内部类 - 可能吗?

是否可以使用内部访问声明 Code First 数据类,如下所示:

internal class Person
{
    public int Id { get; set; }
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我有一个要求,类及其属性不应在程序集外部可见。

entity-framework code-first ef-code-first

6
推荐指数
1
解决办法
2634
查看次数

实体框架代码第一个一对多关系映射与链接表

当两个表之间存在链接(连接)表时,我有一个关于两个表之间的一对多关系的问题.

示例表:

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)

code-first ef-code-first entity-framework-4.1

4
推荐指数
1
解决办法
4653
查看次数