aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-02-19 19:48:24 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-02-19 19:48:24 +0200
commitbbbf67be9caac01ccb671bf3f737200a7320d3e0 (patch)
tree52b2f785bd4c9c8055f6f98ad95cf22a05183e83
parent10e1892e2ff3620d5111c3b8e5c9eea5baa08a1a (diff)
downloadTango-bbbf67be9caac01ccb671bf3f737200a7320d3e0.tar.gz
Tango-bbbf67be9caac01ccb671bf3f737200a7320d3e0.zip
Implemented safe guard for corrupted EF Model Cache.
-rw-r--r--Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnkbin1532 -> 1516 bytes
-rw-r--r--Software/Visual_Studio/Tango.BL/ObservablesContextConfiguration.cs21
2 files changed, 20 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
index 21b63193d..cd233d031 100644
--- a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
+++ b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk
Binary files differ
diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContextConfiguration.cs b/Software/Visual_Studio/Tango.BL/ObservablesContextConfiguration.cs
index 90d78f6bc..07c3f5306 100644
--- a/Software/Visual_Studio/Tango.BL/ObservablesContextConfiguration.cs
+++ b/Software/Visual_Studio/Tango.BL/ObservablesContextConfiguration.cs
@@ -5,6 +5,7 @@ using System.Data.Entity.Infrastructure;
using System.IO;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using Tango.Core.Helpers;
@@ -22,7 +23,25 @@ namespace Tango.BL
public ObservablesContextConfiguration() : base()
{
Directory.CreateDirectory(FolderPath);
- SetModelStore(new DefaultDbModelStore(FolderPath));
+ var modelStore = new DefaultDbModelStore(FolderPath);
+
+ try
+ {
+ modelStore.TryLoad(typeof(ObservablesContext));
+ }
+ catch
+ {
+ try
+ {
+ Directory.Delete(FolderPath, true);
+ Thread.Sleep(1000);
+ Directory.CreateDirectory(FolderPath);
+ }
+ catch { }
+ modelStore = new DefaultDbModelStore(FolderPath);
+ }
+
+ SetModelStore(modelStore);
}
public static void ClearModelStore()