如何使用无键实体类型在 EF 模型中定义查询?

How to define queries inside EF models using keyless entity types?

我刚刚无意中发现了 Entity Framework 名为 Keyless Entity Types. The listed main usage scenarios 的核心功能 提及:

Mapping to queries defined in the model.

我试图使用我最喜欢的搜索引擎找出它们的含义,但找不到任何相关内容。有人可以给我提示或 link 有关如何在 EF Core 模型中定义查询映射的相关文档吗?

非常感谢您!

文档中没有这方面的示例,但它看起来像这样:

        modelBuilder.Entity<BlogPostsCount>(
            eb=>
            {
                eb.HasNoKey();
                eb.ToSqlQuery("select Name, count(*) PostCount from BlogPosts group by Name");
                eb.Property(v => v.BlogName).HasColumnName("Name");
            });