예제 #1
0
        public override void Before(MethodInfo methodUnderTest)
        {
            Database.Delete("DataContext");

            var configuration = new MigrationConfiguration();
            var migrator = new DbSeederMigrator<DataContext>(configuration);
            migrator.MigrateToLatestVersion();
        }
예제 #2
0
        public override void Before(MethodInfo methodUnderTest)
        {
            Database.Delete("DataContext");

            var configuration = new MigrationConfiguration();
            var migrator      = new DbSeederMigrator <DataContext>(configuration);

            migrator.MigrateToLatestVersion();
        }
예제 #3
0
        public KernelEventCompletedArguments Execute()
        {
            // Hhack to disable migrating when visual studio creates migrations.
            // This is due to the fact that EntityFramework uses some static information and this
            // application loads everyting upfront
            if (!System.AppDomain.CurrentDomain.SetupInformation.AppDomainManagerAssembly.Contains(
                    "Microsoft.VisualStudio.Platform.AppDomainManager"))
            {
                var configuration = new MigrationConfiguration();
                var migrator      = new DbSeederMigrator <DataContext>(configuration);

                try
                {
                    migrator.MigrateToLatestVersion();
                }
                catch (System.Exception ex)
                {
                    return(new KernelEventCompletedArguments
                    {
                        AllowContinue = false,
                        KernelEventSucceeded = false,
                        Issues = new IError[]
                        {
                            new GenericError
                            {
                                ErrorMessage = "Could not migrate to latest version.",
                                ErrorException = ex,
                                Severity = ErrorSeverity.Critical
                            }
                        }
                    });
                }
            }

            return(new KernelEventCompletedArguments()
            {
                AllowContinue = true, KernelEventSucceeded = true, Issues = null
            });
        }
예제 #4
0
        public KernelEventCompletedArguments Execute()
        {
            // Hhack to disable migrating when visual studio creates migrations.
            // This is due to the fact that EntityFramework uses some static information and this
            // application loads everyting upfront
            if (!System.AppDomain.CurrentDomain.SetupInformation.AppDomainManagerAssembly.Contains(
                "Microsoft.VisualStudio.Platform.AppDomainManager"))
            {
                var configuration = new MigrationConfiguration();
                var migrator = new DbSeederMigrator<DataContext>(configuration);

                try
                {
                    migrator.MigrateToLatestVersion();
                }
                catch (System.Exception ex)
                {
                    return new KernelEventCompletedArguments
                    {
                        AllowContinue = false,
                        KernelEventSucceeded = false,
                        Issues = new IError[]
                        {
                            new GenericError
                            {
                                ErrorMessage = "Could not migrate to latest version.",
                                ErrorException = ex,
                                Severity = ErrorSeverity.Critical
                            }
                        }
                    };
                }
            }

            return new KernelEventCompletedArguments() { AllowContinue = true, KernelEventSucceeded = true, Issues = null };
        }