public NccDbContext CreateDbContext(string[] args) { var opts = SetupHelper.GetDbContextOptions(); var nccDbConetxt = new NccDbContext(opts); return(nccDbConetxt); }
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()); }
public NccDbContext Create(DbContextFactoryOptions options) { var opts = SetupHelper.GetDbContextOptions(); var nccDbConetxt = new NccDbContext(opts); return(nccDbConetxt); }