Пример #1
0
        public (IUnitOfWork, TypiconDBContext, Action <DbContextOptionsBuilder, IConfiguration>) GetMySQLUnitOfWork(IConfiguration config)
        {
            var optionsBuilder = new DbContextOptionsBuilder <TypiconDBContext>();

            DbOptions.ConfigureMySql(optionsBuilder, config);

            var dbContext = new TypiconDBContext(optionsBuilder.Options);

            return(new UnitOfWork(dbContext, new RepositoryFactory()), dbContext, DbOptions.ConfigureMySql);
        }
Пример #2
0
        private static DbContextOptions <TypiconDBContext> CreateOptions()
        {
            var optionsBuilder = new DbContextOptionsBuilder <TypiconDBContext>();

            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            //MSSql
            //DbOptions.ConfigureMsSql(optionsBuilder);

            //Sqlite
            //DbOptions.ConfigureSqlite(optionsBuilder, config);

            //PostgreSQL
            //DbOptions.ConfigurePostgre(optionsBuilder);

            //MySQL
            DbOptions.ConfigureMySql(optionsBuilder, config);

            return(optionsBuilder.Options);
        }