/// <summary>
        /// 用反射创建DbContext实例
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public T CreateDbContext(string[] args)
        {
            var builder       = new DbContextOptionsBuilder <T>();
            var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

            MySqlDbContextConfigurer.Configure(
                builder,
                configuration.GetConnectionString(ConnectionStringName)
                );
            return((T)Activator.CreateInstance(typeof(T), new object[] { builder.Options }));
        }
Beispiel #2
0
 private void AddMySqlDbContext <TDbContext>()
     where TDbContext : AbpDbContext
 {
     Configuration.Modules.AbpEfCore().AddDbContext <TDbContext>(options =>
     {
         if (options.ExistingConnection != null)
         {
             MySqlDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
         }
         else
         {
             MySqlDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
         }
     });
 }