protected void ModifyDbContext(string[] projectFiles, ModuleInfo module, string startupProject, bool skipDbMigrations = false)
        {
            if (string.IsNullOrWhiteSpace(module.EfCoreConfigureMethodName))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(startupProject))
            {
                startupProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrator.csproj"));
            }

            var dbMigrationsProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrations.csproj"));

            if (dbMigrationsProject == null)
            {
                Logger.LogDebug("Solution doesn't have a \".DbMigrations\" project.");
                return;
            }

            var dbContextFile = DerivedClassFinder.Find(dbMigrationsProject, "AbpDbContext").FirstOrDefault();

            if (dbContextFile == null)
            {
                Logger.LogDebug($"{dbMigrationsProject} project doesn't have a class that is derived from \"AbpDbContext\".");
                return;
            }

            var addedNewBuilder = DbContextFileBuilderConfigureAdder.Add(dbContextFile, module.EfCoreConfigureMethodName);

            if (addedNewBuilder && !skipDbMigrations)
            {
                EfCoreMigrationAdder.AddMigration(dbMigrationsProject, module.Name, startupProject);
            }
        }
Exemple #2
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationManager efCoreMigrationManager,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
     AngularSourceCodeAdder angularSourceCodeAdder,
     NewCommand newCommand,
     BundleCommand bundleCommand,
     CliHttpClientFactory cliHttpClientFactory)
 {
     JsonSerializer                        = jsonSerializer;
     ProjectNugetPackageAdder              = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder    = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationManager                = efCoreMigrationManager;
     DerivedClassFinder                    = derivedClassFinder;
     ProjectNpmPackageAdder                = projectNpmPackageAdder;
     NpmGlobalPackagesChecker              = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler         = remoteServiceExceptionHandler;
     SourceCodeDownloadService             = sourceCodeDownloadService;
     SolutionFileModifier                  = solutionFileModifier;
     NugetPackageToLocalReferenceConverter = nugetPackageToLocalReferenceConverter;
     AngularSourceCodeAdder                = angularSourceCodeAdder;
     NewCommand            = newCommand;
     BundleCommand         = bundleCommand;
     _cliHttpClientFactory = cliHttpClientFactory;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }
Exemple #3
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
     SourceCodeDownloadService sourceCodeDownloadService,
     SolutionFileModifier solutionFileModifier,
     NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter)
 {
     JsonSerializer                        = jsonSerializer;
     ProjectNugetPackageAdder              = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder    = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationAdder                  = efCoreMigrationAdder;
     DerivedClassFinder                    = derivedClassFinder;
     ProjectNpmPackageAdder                = projectNpmPackageAdder;
     NpmGlobalPackagesChecker              = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler         = remoteServiceExceptionHandler;
     SourceCodeDownloadService             = sourceCodeDownloadService;
     SolutionFileModifier                  = solutionFileModifier;
     NugetPackageToLocalReferenceConverter = nugetPackageToLocalReferenceConverter;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }
Exemple #4
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder)
 {
     EfCoreMigrationAdder               = efCoreMigrationAdder;
     DerivedClassFinder                 = derivedClassFinder;
     JsonSerializer                     = jsonSerializer;
     ProjectNugetPackageAdder           = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder = dbContextFileBuilderConfigureAdder;
     ProjectNpmPackageAdder             = projectNpmPackageAdder;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }
Exemple #5
0
 public SolutionModuleAdder(
     IJsonSerializer jsonSerializer,
     ProjectNugetPackageAdder projectNugetPackageAdder,
     DbContextFileBuilderConfigureAdder dbContextFileBuilderConfigureAdder,
     EfCoreMigrationAdder efCoreMigrationAdder,
     DerivedClassFinder derivedClassFinder,
     ProjectNpmPackageAdder projectNpmPackageAdder,
     NpmGlobalPackagesChecker npmGlobalPackagesChecker,
     IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
 {
     JsonSerializer                     = jsonSerializer;
     ProjectNugetPackageAdder           = projectNugetPackageAdder;
     DbContextFileBuilderConfigureAdder = dbContextFileBuilderConfigureAdder;
     EfCoreMigrationAdder               = efCoreMigrationAdder;
     DerivedClassFinder                 = derivedClassFinder;
     ProjectNpmPackageAdder             = projectNpmPackageAdder;
     NpmGlobalPackagesChecker           = npmGlobalPackagesChecker;
     RemoteServiceExceptionHandler      = remoteServiceExceptionHandler;
     Logger = NullLogger <SolutionModuleAdder> .Instance;
 }