private static void EnsureServices(IServiceProvider services)
        {
            var providerServices = services.GetRequiredService <IDatabaseProviderServices>();

            if (!(providerServices is IRelationalDatabaseProviderServices))
            {
                throw new OperationException(CommandsStrings.NonRelationalProvider(providerServices.InvariantName));
            }
        }
Ejemplo n.º 2
0
        private void EnsureServices(IServiceProvider services)
        {
            var providerServices = services.GetRequiredService <IDatabaseProviderServices>();

            if (!(providerServices is IRelationalDatabaseProviderServices))
            {
                throw new OperationException(CommandsStrings.NonRelationalProvider(providerServices.InvariantName));
            }

            var options      = services.GetRequiredService <IDbContextOptions>();
            var contextType  = services.GetRequiredService <DbContext>().GetType();
            var assemblyName = RelationalOptionsExtension.Extract(options).MigrationsAssembly
                               ?? contextType.GetTypeInfo().Assembly.GetName().Name;

            if (_assemblyName != assemblyName)
            {
                throw new OperationException(CommandsStrings.MigrationsAssemblyMismatch(_assemblyName, assemblyName));
            }
        }