Skip to content

Commit b5c174d

Browse files
author
jaguzman
committed
Changed the ado.net context to only include mapped properties in the table creation query
1 parent ea17ad4 commit b5c174d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/DotNetToolkit.Repository.AdoNet/Internal/Schema/SchemaTableConfigurationHelper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private void ValidateTable(Type entityType, IEnumerable<SchemaTableColumn> schem
224224

225225
var propertiesMapping = entityType
226226
.GetRuntimeProperties()
227-
.Where(x => x.IsPrimitive())
227+
.Where(x => x.IsPrimitive() && _dbHelper.Conventions.IsColumnMapped(x))
228228
.OrderBy(_dbHelper.Conventions.GetColumnOrderOrDefault)
229229
.ToDictionary(_dbHelper.Conventions.GetColumnName, x => x);
230230

@@ -489,11 +489,14 @@ private string PrepareCreateTableQuery(Type entityType)
489489

490490
// Check if has composite foreign keys (more than one key for a given navigation property), and if so, it needs to defined an ordering
491491
var propertiesMapping = properties
492-
.Where(x => x.IsPrimitive())
492+
.Where(x => x.IsPrimitive() && _dbHelper.Conventions.IsColumnMapped(x))
493493
.OrderBy(_dbHelper.Conventions.GetColumnOrderOrDefault)
494494
.ToDictionary(_dbHelper.Conventions.GetColumnName, x => x);
495495

496-
var primaryKeyPropertyInfosMapping = _dbHelper.Conventions.GetPrimaryKeyPropertyInfos(entityType).ToDictionary(_dbHelper.Conventions.GetColumnName, x => x);
496+
var primaryKeyPropertyInfosMapping = _dbHelper.Conventions
497+
.GetPrimaryKeyPropertyInfos(entityType)
498+
.ToDictionary(_dbHelper.Conventions.GetColumnName, x => x);
499+
497500
var primaryKeyConstraints = new List<string>();
498501
var foreignKeyConstraints = new Dictionary<string, List<Tuple<string, string>>>();
499502
var foreignKeyOrder = 0;

0 commit comments

Comments
 (0)