public static void AddEfDbContext <TContext>(this IServiceCollection services, Action <EFDataOptions> action)
            where TContext : DbContext
        {
            var options = new EFDataOptions();

            action(options);

            services.AddDbContext <TContext>(o =>
            {
                ConfigurationDbContextBuild(o, options);
            });
        }
        public static IEFDbContextBuilder CreateBuilder(EFDataOptions eFDataOptions)
        {
            switch (eFDataOptions.DbType)
            {
            case DatabaseType.Sqlite:
                return(new SqliteDbContextBuilder());

            case DatabaseType.MsSql:
                return(new MsSqlDbContextBuilder());

            default:
                throw new ArgumentOutOfRangeException("don't support db type!");
            }
        }
        private static void ConfigurationDbContextBuild(DbContextOptionsBuilder o, EFDataOptions options)
        {
            var build = EFDbContextBuilderFactory.CreateBuilder(options);

            build.Build(o, options);
        }
Exemplo n.º 4
0
 public void Build(DbContextOptionsBuilder contextOptionsBuilder, EFDataOptions eFDataOptions)
 {
     contextOptionsBuilder.UseSqlServer(eFDataOptions.Connection);
 }