Пример #1
0
        public static void Add()
        {
            //Assembly Assembl = Assembly.GetAssembly(typeof(Program));
            ////Type typse = typeof(Program);
            ////Console.WriteLine(typse.);
            //var serviceDescriptors = new ServiceCollection();


            ////构建容器
            //IServiceProvider serviceProvider = serviceDescriptors.BuildServiceProvider();
            //var dc = serviceProvider.GetService<UwlDbContext>();
            using (var dc = new UwlDbContext())
            {
                if (dc.Database.GetPendingMigrations().Any())
                {
                    Console.WriteLine(" Performing migration / 执行迁移中");
                    dc.Database.Migrate();
                    Console.WriteLine(" Migration completed  / 迁移完成");
                }
                else
                {
                    Console.WriteLine(" No files found to migrate / 未找到需要迁移的文件");
                }
                Console.WriteLine(" press any key to exit");
                Console.ReadLine();
            }
        }
Пример #2
0
 /// <summary>
 /// 通过构造函数注入得到数据库上下文对象实例
 /// </summary>
 /// <param name="coreDbContext"></param>
 public UwlRepositoryBase(UwlDbContext uwlDbContext)
 {
     _uwldbContext = uwlDbContext;
 }
Пример #3
0
 public CoreRepositoryBase(UwlDbContext uwlDbContext) : base(uwlDbContext)
 {
 }
Пример #4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="uwlDbContext"></param>
 public UnitofWorkBase(UwlDbContext uwlDbContext)
 {
     _uwldbContext = uwlDbContext;
     HasCommited   = false;
 }