Exemplo n.º 1
0
        public NccDbContext CreateDbContext(string[] args)
        {
            var opts         = SetupHelper.GetDbContextOptions();
            var nccDbConetxt = new NccDbContext(opts);

            return(nccDbConetxt);
        }
Exemplo n.º 2
0
        public static bool InitilizeDatabase(SupportedDatabases database, string connectionString)
        {
            var builder = new DbContextOptionsBuilder <NccDbContext>();

            switch (database)
            {
            case SupportedDatabases.MSSQL:
                builder.UseSqlServer(SetupHelper.ConnectionString, opts => opts.MigrationsAssembly("NetCoreCMS.Framework"));
                break;

            case SupportedDatabases.MsSqlLocalStorage:
                break;

            case SupportedDatabases.MySql:
                builder.UseMySql(SetupHelper.ConnectionString, opts => opts.MigrationsAssembly("NetCoreCMS.Framework"));
                break;

            case SupportedDatabases.SqLite:
                builder.UseSqlite(SetupHelper.ConnectionString, opts => opts.MigrationsAssembly("NetCoreCMS.Framework"));
                break;

            case SupportedDatabases.PgSql:
                break;
            }
            //builder.UseSqlite(connectionString, options => options.MigrationsAssembly("NetCoreCMS.Framework"));


            var dbContext = new NccDbContext(builder.Options);

            dbContext.Database.Migrate();
            return(dbContext.Database.EnsureCreated());
        }
Exemplo n.º 3
0
        public NccDbContext Create(DbContextFactoryOptions options)
        {
            var opts         = SetupHelper.GetDbContextOptions();
            var nccDbConetxt = new NccDbContext(opts);

            return(nccDbConetxt);
        }