diff --git a/EntityFramework.Utilities/.vs/EntityFramework.Utilities/v15/Server/sqlite3/db.lock b/EntityFramework.Utilities/.vs/EntityFramework.Utilities/v15/Server/sqlite3/db.lock
new file mode 100644
index 0000000..e69de29
diff --git a/EntityFramework.Utilities/.vs/EntityFramework.Utilities/v15/Server/sqlite3/storage.ide b/EntityFramework.Utilities/.vs/EntityFramework.Utilities/v15/Server/sqlite3/storage.ide
new file mode 100644
index 0000000..88e53e7
Binary files /dev/null and b/EntityFramework.Utilities/.vs/EntityFramework.Utilities/v15/Server/sqlite3/storage.ide differ
diff --git a/EntityFramework.Utilities/.vs/config/applicationhost.config b/EntityFramework.Utilities/.vs/config/applicationhost.config
new file mode 100644
index 0000000..f3e21da
--- /dev/null
+++ b/EntityFramework.Utilities/.vs/config/applicationhost.config
@@ -0,0 +1,1021 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EntityFramework.Utilities/EntityFramework.Utilities/App.config b/EntityFramework.Utilities/EntityFramework.Utilities/App.config
index 21e7063..a2c109b 100644
--- a/EntityFramework.Utilities/EntityFramework.Utilities/App.config
+++ b/EntityFramework.Utilities/EntityFramework.Utilities/App.config
@@ -1,17 +1,17 @@
-
+
-
+
-
+
-
+
-
\ No newline at end of file
+
diff --git a/EntityFramework.Utilities/EntityFramework.Utilities/EntityFramework.Utilities.csproj b/EntityFramework.Utilities/EntityFramework.Utilities/EntityFramework.Utilities.csproj
index 75bd2c5..db5159f 100644
--- a/EntityFramework.Utilities/EntityFramework.Utilities/EntityFramework.Utilities.csproj
+++ b/EntityFramework.Utilities/EntityFramework.Utilities/EntityFramework.Utilities.csproj
@@ -1,5 +1,5 @@
-
+
Debug
@@ -11,6 +11,7 @@
EntityFramework.Utilities
v4.0
512
+
true
@@ -20,6 +21,7 @@
DEBUG;TRACE
prompt
4
+ false
pdbonly
@@ -28,6 +30,7 @@
TRACE
prompt
4
+ false
diff --git a/EntityFramework.Utilities/EntityFramework.Utilities/MappingHelper.cs b/EntityFramework.Utilities/EntityFramework.Utilities/MappingHelper.cs
index 1100b1a..164a003 100644
--- a/EntityFramework.Utilities/EntityFramework.Utilities/MappingHelper.cs
+++ b/EntityFramework.Utilities/EntityFramework.Utilities/MappingHelper.cs
@@ -186,14 +186,19 @@ public EfMapping(DbContext db)
return GetClrTypeFromTypeMapping(metadata, objectItemCollection, m.TypeMapping as EntityTypeMapping);
};
+
if (mapping.EntityTypeMappings.Any(m => m.IsHierarchyMapping))
{
var withConditions = mapping.EntityTypeMappings.Where(m => m.Fragments[0].Conditions.Any()).ToList();
- tableMapping.TPHConfiguration = new TPHConfiguration
- {
- ColumnName = withConditions.First().Fragments[0].Conditions[0].Column.Name,
- Mappings = new Dictionary()
- };
+
+ if (withConditions.Count > 0)
+ {
+ tableMapping.TPHConfiguration = new TPHConfiguration
+ {
+ ColumnName = withConditions.First().Fragments[0].Conditions[0].Column.Name,
+ Mappings = new Dictionary()
+ };
+ }
foreach (var item in withConditions)
{
tableMapping.TPHConfiguration.Mappings.Add(
diff --git a/EntityFramework.Utilities/Tests/EfMappingFactoryTests.cs b/EntityFramework.Utilities/Tests/EfMappingFactoryTests.cs
new file mode 100644
index 0000000..70286a0
--- /dev/null
+++ b/EntityFramework.Utilities/Tests/EfMappingFactoryTests.cs
@@ -0,0 +1,24 @@
+using EntityFramework.Utilities;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Tests.FakeDomain;
+
+namespace Tests
+{
+
+ [TestClass]
+ public class EfMappingFactoryTests
+ {
+ [TestMethod]
+
+ public void ShouldGetMappingsForContext()
+ {
+ var ctx = Context.Sql();
+ var m = EfMappingFactory.GetMappingsForContext(ctx);
+ Assert.IsNotNull(m);
+ }
+ }
+}
diff --git a/EntityFramework.Utilities/Tests/FakeDomain/Context.cs b/EntityFramework.Utilities/Tests/FakeDomain/Context.cs
index ca0fafa..845b863 100644
--- a/EntityFramework.Utilities/Tests/FakeDomain/Context.cs
+++ b/EntityFramework.Utilities/Tests/FakeDomain/Context.cs
@@ -23,6 +23,7 @@ private Context(string connectionString)
public DbSet PhoneNumbers { get; set; }
public DbSet Emails { get; set; }
public DbSet Comments { get; set; }
+ public DbSet ApprovedComments { get; set; }
public DbSet NumericTestsObjects { get; set; }
public DbSet MultiPKObjects { get; set; }
diff --git a/EntityFramework.Utilities/Tests/Models/Comment.cs b/EntityFramework.Utilities/Tests/Models/Comment.cs
index 684a948..c453c29 100644
--- a/EntityFramework.Utilities/Tests/Models/Comment.cs
+++ b/EntityFramework.Utilities/Tests/Models/Comment.cs
@@ -1,15 +1,25 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
namespace Tests.FakeDomain.Models
{
+ [Table("Comment")]
public class Comment
{
+ [Key]
public int Id { get; set; }
public string Text { get; set; }
public int PostId { get; set; }
public BlogPost Post { get; set; }
}
+
+ [Table("ApprovedComment")]
+ public class ApprovedComment:Comment
+ {
+ public DateTime ApprovedOn { get; set; }
+ }
}
diff --git a/EntityFramework.Utilities/Tests/Tests.csproj b/EntityFramework.Utilities/Tests/Tests.csproj
index de83706..78f4db4 100644
--- a/EntityFramework.Utilities/Tests/Tests.csproj
+++ b/EntityFramework.Utilities/Tests/Tests.csproj
@@ -76,6 +76,7 @@
+