efcore
efcore copied to clipboard
SplitQuery per-table definition
Currently (AFAIK) it's only possible to either have SingleQuery or SplitQuery defined globally for all queries, or per-query. Would have been really helpful being able to set the default split query mode per table. Consider a blogs -> posts relation, our blog has a logo column with max 4MB of data per row. Joining the blog with its 10K posts can be devastating.
I think it should also be possible to set the mode by entity:
public class BlogConfiguration IEntityTypeConfiguration<BlogEntity>
{
public void Configure(EntityTypeBuilder<BlogEntity> builder)
{
builder.Property(entity => entity.Logo).HasMaxLength(1024 * 1024 * 4);
builder.WithSplitQuery(true);
}
}
Note from triage: also consider configuration per navigation property.
@ajcvickers any chance seeing this land soon? 🙏 (I wish I could contribute this myself, but my understanding of EF under the hood is minimal at best, maybe a good (non realistic) new year resolution...)
@gdoron there are hardly any votes for this feature, so it's unlikely we'd work on this before the many other highly-voted features on the list...
I'm currently transitioning from NHibernate after having not looked at EF for years; I'm really impressed with where it is at now.
NHibernate collection mappings provide options.Fetch(CollectionFetchMode.Select). This is so far the only thing I've not been able to do with EF that I really really really need. Big vote from me on this (we purely use owned entities with ToTable so need it in that context).
@simonfox note that you can opt into split queries globally (docs. This issue is about setting a default on a per-table basis.
@roji yes understand that, and am using that for now. My NHibernate example is a per relationship mapping option.