Using non-generic Find, such as await context.FindAsync(typeof(Post), 77); is not translated to ReadItem and instead results in a normal query:
SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Post") AND (c["Id"] = @__p_0))
OFFSET 0 LIMIT 1
Repro
using (var context = new AppDbContext())
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
context.Add(new Post { Id = 77 } );
await context.SaveChangesAsync();
}
using (var context = new AppDbContext())
{
var x = await context.FindAsync(typeof(Post), 77);
}
public class AppDbContext : DbContext
{
public DbSet<Post> Posts => Set<Post>();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseCosmos(
"https://localhost:8081",
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
"EFDatabase")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
}
public class Post
{
public int Id { get; set; }
public string? Title { get; set; }
}
Using non-generic Find, such as
await context.FindAsync(typeof(Post), 77);is not translated to ReadItem and instead results in a normal query:Repro