private void Initialize(bool isMasterDb = false) { try { string connString = ConnStr; if (ConnStr.Contains(DBNAME_PLACEHOLDER)) { Database.Connection.ConnectionString = connString.Replace(DBNAME_PLACEHOLDER, DatabaseName); } else { Database.Connection.ConnectionString = connString; } if (isMasterDb) { System.Data.Entity.Database.SetInitializer <RlmDbEntities>(null); } else { System.Data.Entity.Database.SetInitializer <RlmDbEntities>(new RLMCreateDBIfNotExists()); } //Database.SetInitializer<RnnDbEntities>(new MigrateDatabaseToLatestVersion<RnnDbEntities, Configuration>(true)); //Database.SetInitializer<RnnDbEntities>(null); ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = 0; } catch (Exception Ex) { System.Diagnostics.Debug.WriteLine(Ex.ToString()); throw; } }
/// <summary> /// 初始化 /// </summary> /// <param name="connStr">链接字符串</param> public void Init(string connStr = null) { // 如果初始化参数为空,使用默认参数 if (!string.IsNullOrEmpty(connStr)) { if (ConnStr.Contains(";")) { var m = ToLink(connStr); ConnStr = string.Format("{0}@{1}:{2}", m.Password, m.Server, m.Port); if (long.TryParse(m.Database, out var db)) { DB = db; } } else { ConnStr = connStr; } } conn = new PooledRedisClientManager(10000, 10, new string[] { ConnStr }) { ConnectTimeout = 1200000 // 1000 * 60 * 20 }; }