| | |
| | | /// 初始数据库建立 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string CreateDatabase(bool cover = true) { |
| | | public static string CreateDatabase(bool cover = false) { |
| | | try { |
| | | var db = DbHelper.GetDbClient(); |
| | | |
| | | var entityTypes = new Type[] { |
| | | typeof(TN_CAR_IN), |
| | | typeof(TN_CG_Detail), |
| | | typeof(TN_Container), |
| | | typeof(TN_Loc_Container), |
| | | typeof(TN_Location), |
| | | typeof(TN_Task), |
| | | typeof(TN_Task_Action), |
| | | typeof(SysHelper.OI_SYS_MAXID), |
| | | //typeof(TN_CAR_IN), |
| | | //typeof(TN_CG_Detail), |
| | | //typeof(TN_Container), |
| | | //typeof(TN_Loc_Container), |
| | | //typeof(TN_Location), |
| | | //typeof(TN_Task), |
| | | //typeof(TN_Task_Action), |
| | | //typeof(SysHelper.OI_SYS_MAXID), |
| | | |
| | | typeof(TN_Inbound_Order), |
| | | //typeof(TN_Inbound_Order), |
| | | typeof(TN_Check_Detail), |
| | | typeof(TN_Check_Order), |
| | | typeof(TN_CNTR_ITEM), |
| | | typeof(TN_Outbound_Detail), |
| | | typeof(TN_Outbound_Order), |
| | | //typeof(TN_Check_Order), |
| | | //typeof(TN_CNTR_ITEM), |
| | | //typeof(TN_Outbound_Detail), |
| | | //typeof(TN_Outbound_Order), |
| | | //typeof(TN_Shift_Order), |
| | | //typeof(TN_Shift_Detail) |
| | | }; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (cover) { |
| | | // 删除所有表(按依赖关系倒序) |
| | | var tables = db.DbMaintenance.GetTableInfoList(); |
| | | foreach (var table in tables.OrderByDescending(t => t.Name)) { |
| | | db.DbMaintenance.DropTable(table.Name); |
| | | } |
| | | //var tables = db.DbMaintenance.GetTableInfoList(); |
| | | //foreach (var table in tables.OrderByDescending(t => t.Name)) { |
| | | // db.DbMaintenance.DropTable(table.Name); |
| | | //} |
| | | |
| | | // 创建新表 |
| | | db.CodeFirst.InitTables(entityTypes); |