我需要将实体切换到内部.所以我创造了它.没有构建/运行时错误.但是当我想使用DbSet对象时我不能,因为对象似乎没有初始化!
我的ContextEntities:
public partial class Entities
{
internal DbSet<Employee> EmployeeSet { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我用这样的:
Entities context = new Entities();
List<Employee> employees = context.EmployeeSet.ToList();
Run Code Online (Sandbox Code Playgroud)
但"EmployeeSet"为空.我认为这是因为它没有在get中实例化.如果我像这样使用public,它可以工作:
public partial class Entities
{
public DbSet<Employee> EmployeeSet { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
问题:如果DbSet标记为内部,它可以工作吗?如果是这样的话?为什么会破坏它?(谢谢Scott Stafford)