dotnet / dotnet/EntityFramework.Docs
EF Core 10 - Compiled Model in combination with Lazy Loading is supported
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
### Type of issue
Typo
### Description
The limitations of using a compiled model states that it cannot be used in combination with lazy loading proxies, but I have tested this, and in EF Core 10 it works without any error. Is this an old limitation which was valid in earlier versions?
In Program.cs:
`builder.Services.AddDbContext(options =>
options
.UseSqlServer(builder.Configuration.GetConnectionString(nameof(MyContext)))
.UseModel(MyContextModel.Instance).UseLazyLoadingProxies());`
The entities (simplified):
`public partial class User
{
public int Id { get; set; }
public int CompanyId { get; set; }
public virtual Company Company { get; set; }
}`
`public partial class Company
{
...
}`
Some LINQ somewhere in code:
`Context.User.Where(w => w.Id == 1).Select(s => s.Company).FirstOrDefault();`
It fetches the Company and the objects show they have a LazyLoader attached to them.
### Page URL
https://learn.microsoft.com/en-us/ef/core/performance/advanced-performance-topics?tabs=with-di%2Cexpression-api-with-constant#limitations-1
### Content source URL
https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/performance/advanced-performance-topics.md
### Document Version Independent Id
e96b453f-0256-8bc9-bd21-1343f2fe246c
### Platform Id
ada64a4c-83c3-6714-0fa4-d80a203f4349
### Article author
@roji
Contributor guide
Assessment
This issue has not been assessed yet.