예제 #1
0
파일: Program.cs 프로젝트: wk-j/json-import
        static DynamicContext CreateContext(string connectionString, Type targetType)
        {
            var modelOptions = new ModelOptions {
                ModelType = targetType
            };

            var collection = new ServiceCollection();

            collection.AddLogging(builder => {
                builder.AddConsole();
            });

            collection.AddSingleton <ModelOptions>(modelOptions);
            collection.AddDbContext <DynamicContext>(builder => {
                builder.UseNpgsql(connectionString);
            });

            var provider = collection.BuildServiceProvider();
            var context  = provider.GetService <DynamicContext>();

            return(context);
        }
예제 #2
0
 public DynamicContext(DbContextOptions options, ModelOptions modelOptions) : base(options)
 {
     this.modelOptions = modelOptions;
 }