Eager loading include with using UseLazyLoadingProxies

寵の児 提交于 2019-12-06 07:20:13

Auther V, a developer working on EFC has confirmed that this is a bug.

https://github.com/aspnet/EntityFrameworkCore/issues/15170

Documentation about this change

It is fixed in EF Core 3.0.0 RC4 but as of writing this, is not available in the public domain. I personally would not suggest using RC4 as it is still in development and is not well suited for general purpose or production use.

For now, you can suppress the error like so:

protected override void OnConfiguring(DbContextOptionsBuilder optionbuilder)
{
    optionbuilder.UseSqlite(@"Data Source=Data.db").UseLazyLoadingProxies();
    optionbuilder.ConfigureWarnings(w => w.Ignore(CoreEventId.LazyLoadOnDisposedContextWarning));
}

The optionbuilder.ConfigureWarnings(w => w.Ignore(CoreEventId.LazyLoadOnDisposedContextWarning)); line is what you'd need.

But please be aware that any improper usage of lazy loading will also be ignored providing nulled variants when object traveseral is attempted for closed DBContext instances.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!