From 4a32977e35bb494da8dec1327db544f790374b8b Mon Sep 17 00:00:00 2001 From: Sean Fuhrmann Date: Wed, 6 Apr 2022 15:08:36 -0500 Subject: [PATCH] Adding support from checking first object in collection if TEntity does not find a a model match --- src/FlexLabs.EntityFrameworkCore.Upsert/UpsertCommandBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FlexLabs.EntityFrameworkCore.Upsert/UpsertCommandBuilder.cs b/src/FlexLabs.EntityFrameworkCore.Upsert/UpsertCommandBuilder.cs index 341d535..a6af141 100644 --- a/src/FlexLabs.EntityFrameworkCore.Upsert/UpsertCommandBuilder.cs +++ b/src/FlexLabs.EntityFrameworkCore.Upsert/UpsertCommandBuilder.cs @@ -39,6 +39,7 @@ internal UpsertCommandBuilder(DbContext dbContext, ICollection entities _entities = entities; _entityType = dbContext.GetService().FindEntityType(typeof(TEntity)) + ?? (entities.Count == 0 ? null : dbContext.GetService().FindEntityType(entities.First().GetType())) ?? throw new InvalidOperationException(Resources.EntityTypeMustBeMappedInDbContext); }