I must be missing something simple. I have created a project to hold data models. I have added the following packages:
I created the models using the following command in the Package Manager Console:
Scaffold-DbContext "server=MyServer;database=MyDB;Integrated Security=False;User ID=MyUserId;Password=myPassword;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Now I have a context called MyDBContext. However, I don't seem to have the methods required to write the LINQ queries I was expecting. I was hoping to be able to write something like this:
var pt = context.Patient.Where(p => p.PatientId == 1234)
.Include(pa => pa.PatientAddress)
.ThenInclude(....)
ThenInclude is not available. What am I missing?
On a side note, I was expecting the DbSets to be pluralized. Why didn't this happen?
Edit
First you have to include the extensions in your class:
using Microsoft.EntityFrameworkCore;
Original answer
It exists, but:
Code completion still does not offer up properties in ThenInclude. e.g., Author not an option in the docs example:
var blogs = context.Blogs .Include(blog => blog.Posts) .ThenInclude(post => post.Author) .ToList();
When entered manually, compiles with no errors or underlining and runs correctly.
See https://github.com/dotnet/roslyn/issues/8237#issuecomment-562997436