From d24a7110e2eba64febf49f9f1907f4132b7aeae5 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Fri, 14 Aug 2020 15:11:07 -0700 Subject: [PATCH] Use CreateFactory instead of CreateInstance in DbContextFactory Fixes #21651 --- src/EFCore/Internal/DbContextFactorySource.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EFCore/Internal/DbContextFactorySource.cs b/src/EFCore/Internal/DbContextFactorySource.cs index 11776605e7b..66f126e2fe5 100644 --- a/src/EFCore/Internal/DbContextFactorySource.cs +++ b/src/EFCore/Internal/DbContextFactorySource.cs @@ -67,7 +67,9 @@ var constructors } } - return (p, _) => ActivatorUtilities.CreateInstance(p); + var factory = ActivatorUtilities.CreateFactory(typeof(TContext), new Type[0]); + + return (p, _) => (TContext)factory(p, null); } } }