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

            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;
            }

            DbContextFileBuilderConfigureAdder.Add(dbContextFile, module.EfCoreConfigureMethodName);


            if (!skipDbMigrations)
            {
                EfCoreMigrationAdder.AddMigration(dbMigrationsProject, module.Name, startupProject);
            }
        }
Beispiel #2
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;
 }