当我调用数据模型上下文类时引发System.StackOverflowException错误

时间:2019-11-10 10:59:49

标签: c# asp.net entity-framework

数据模型上下文:

using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class ExampleEntities : DbContext
{
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        throw new UnintentionalCodeFirstException();
    }

    public virtual DbSet<Example1> Example1 { get; set; }
    public virtual DbSet<Example2> Example { get; set; }
    public virtual DbSet<Example3> Example3 { get; set; }
    public virtual DbSet<Example4> Example4 { get; set; }
}

然后,当我尝试初始化上下文时,将其放在数据访问层文件中,

private ExampleEntities _context = new ExampleEntities(); 
  

{“引发了类型为'System.StackOverflowException'的异常。”}   enter image description here

抛出此异常。

0 个答案:

没有答案