private static void GetBulkInfrstructure <TEntity>(DbContext context, out IInfrastructure <IServiceProvider> sp, out IEntityType entity, out IRelationalConnection relationalConnection) { sp = (IInfrastructure <IServiceProvider>)context; var options = sp.GetService <IDbContextOptions>(); entity = context.Model.FindEntityType(typeof(TEntity)); if (entity == null) { throw new NotSupportedException($"The type {typeof(TEntity)} is not part of the EntityFramework metadata model. Only mapped entities are supported."); } relationalConnection = sp.GetService <IRelationalConnection>(); }
public static TService TryGetService <TService>([NotNull] this IInfrastructure <IServiceProvider> accessor) { try { return(accessor.GetService <TService>()); } catch { return(default);
public static StoreOptions zGetStoreOptions(this IInfrastructure <IServiceProvider> accessor) => accessor.GetService <IDbContextOptions>().Extensions .OfType <CoreOptionsExtension>().FirstOrDefault()? .ApplicationServiceProvider?.GetService <IOptions <IdentityOptions> >()?.Value?.Stores;