diff --git a/Bootstrap.DataAccess/DbManager.cs b/Bootstrap.DataAccess/DbManager.cs index 0ea0ef27..d1c407f9 100644 --- a/Bootstrap.DataAccess/DbManager.cs +++ b/Bootstrap.DataAccess/DbManager.cs @@ -9,6 +9,7 @@ namespace Bootstrap.DataAccess /// public static class DbManager { + private static readonly object _locker = new object(); /// /// /// @@ -16,7 +17,13 @@ namespace Bootstrap.DataAccess /// public static IDatabase Create(string connectionName = null, bool keepAlive = false) { - if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); + if (Mappers.GetMapper(typeof(Exceptions), null) == null) + { + lock (_locker) + { + if (Mappers.GetMapper(typeof(Exceptions), null) == null) Mappers.Register(typeof(Exceptions).Assembly, new BootstrapDataAccessConventionMapper()); + } + } var db = Longbow.Data.DbManager.Create(connectionName, keepAlive); db.ExceptionThrown += (sender, args) => args.Exception.Log(new NameValueCollection() { ["LastCmd"] = db.LastCommand }); return db;