C# 如何在asp Net Zero中调试EF

C# 如何在asp Net Zero中调试EF,c#,entity-framework,aspnetboilerplate,C#,Entity Framework,Aspnetboilerplate,在典型的MCV项目中,为了调试实体框架,我会 using (var context = new BlogContext()) { context.Database.Log = s => Debug.WriteLine(s); //generated sql is now in output window } 看起来asp net zero通过使用存储库模式使我的生活变得更轻松。访问EF正在运行的原始sql的新的和改进的方法是什么 这就是解决方案 using System.

在典型的MCV项目中,为了调试实体框架,我会

using (var context = new BlogContext())
{
    context.Database.Log = s => Debug.WriteLine(s);
    //generated sql is now in output window
}
看起来asp net zero通过使用存储库模式使我的生活变得更轻松。访问EF正在运行的原始sql的新的和改进的方法是什么

这就是解决方案

using System.Diagnostics;
using System.Web.Mvc;
using Abp.Domain.Repositories;
using Abp.EntityFramework.Repositories;

namespace AspNetZero.WebSite.Web.Controllers
{
    public class MyController : WebSiteControllerBase
    {
        private readonly IRepository<MyEntity> _myEntityRepository;

        public MyController(IRepository<MyEntity> myEntityRepository)
        {
            myEntityRepository.GetDbContext().Database.Log = s => Debug.WriteLine(s);
        }
    }
}
使用系统诊断;
使用System.Web.Mvc;
使用Abp.Domain.Repositories;
使用Abp.EntityFramework.Repositories;
命名空间AspNetZero.WebSite.Web.Controllers
{
公共类MyController:WebSiteControllerBase
{
私人只读易读存储库;
公共MyController(免疫性髓鞘再生)
{
myEntityRepository.GetDbContext().Database.Log=s=>Debug.WriteLine;
}
}
}
这就是解决方案

using System.Diagnostics;
using System.Web.Mvc;
using Abp.Domain.Repositories;
using Abp.EntityFramework.Repositories;

namespace AspNetZero.WebSite.Web.Controllers
{
    public class MyController : WebSiteControllerBase
    {
        private readonly IRepository<MyEntity> _myEntityRepository;

        public MyController(IRepository<MyEntity> myEntityRepository)
        {
            myEntityRepository.GetDbContext().Database.Log = s => Debug.WriteLine(s);
        }
    }
}
使用系统诊断;
使用System.Web.Mvc;
使用Abp.Domain.Repositories;
使用Abp.EntityFramework.Repositories;
命名空间AspNetZero.WebSite.Web.Controllers
{
公共类MyController:WebSiteControllerBase
{
私人只读易读存储库;
公共MyController(免疫性髓鞘再生)
{
myEntityRepository.GetDbContext().Database.Log=s=>Debug.WriteLine;
}
}
}

设置断点并调试。没有什么变化。设置断点并调试。没有什么变化。