From 0f3b267dd37feb33caeb3489b8b640e26fe70c04 Mon Sep 17 00:00:00 2001 From: Atiqur Rahman Foyshal Date: Thu, 20 Nov 2025 13:50:52 +0600 Subject: [PATCH 1/4] Add support TableFor with Alter, Delete and Schema --- .../Extensions/FluentMigratorExtensions.cs | 39 ++++++++++++++- .../UpgradeTo490/SchemaMigration.cs | 47 +++++++++---------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs index 81f9d6f88f8..bbede67a9c6 100644 --- a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs +++ b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs @@ -1,9 +1,13 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Data; using System.Reflection; +using FluentMigrator.Builders.Alter; using FluentMigrator.Builders.Alter.Table; using FluentMigrator.Builders.Create; using FluentMigrator.Builders.Create.Table; +using FluentMigrator.Builders.Delete; +using FluentMigrator.Builders.Schema; +using FluentMigrator.Builders.Schema.Table; using FluentMigrator.Infrastructure.Extensions; using FluentMigrator.Model; using FluentMigrator.Runner; @@ -63,7 +67,7 @@ private static void DefineByOwnType(string columnName, Type propType, CreateTabl /// The builder to add the database engine(s) to /// The migration runner builder public static IMigrationRunnerBuilder AddNopDbEngines(this IMigrationRunnerBuilder builder) - { + { if (!DataSettingsManager.IsDatabaseInstalled()) return builder.AddSqlServer().AddMySql5().AddPostgres92(); @@ -145,6 +149,39 @@ public static void TableFor(this ICreateExpressionRoot expressionRoot) builder.RetrieveTableExpressions(type); } + /// + /// Retrieves expressions into IDeleteExpressionRoot + /// + /// The root expression for a DELETE operation + /// Entity type + public static void TableFor(this IDeleteExpressionRoot expressionRoot) where TEntity : BaseEntity + { + var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); + expressionRoot.Table(tableName); + } + + /// + /// Retrieves expressions into IAlterExpressionRoot + /// + /// The root expression for a ALTER operation + /// Entity type + public static IAlterTableAddColumnOrAlterColumnOrSchemaOrDescriptionSyntax TableFor(this IAlterExpressionRoot expressionRoot) where TEntity : BaseEntity + { + var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); + return expressionRoot.Table(tableName); + } + + /// + /// Retrieves expressions into IAlterExpressionRoot + /// + /// The root expression for a SCHEMA + /// Entity type + public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot schema) + { + var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); + return schema.Table(tableName); + } + /// /// Retrieves expressions for building an entity table /// diff --git a/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs b/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs index 3e12547f59e..6cbd40d17a5 100644 --- a/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs +++ b/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs @@ -15,12 +15,10 @@ public class SchemaMigration : ForwardOnlyMigration public override void Up() { //#7387 - var productTableName = nameof(Product); - var ageVerificationColumnName = nameof(Product.AgeVerification); - if (!Schema.Table(productTableName).Column(ageVerificationColumnName).Exists()) + if (!Schema.TableFor().Column(ageVerificationColumnName).Exists()) { - Alter.Table(productTableName) + Alter.TableFor() .AddColumn(ageVerificationColumnName) .AsBoolean() .NotNullable() @@ -28,9 +26,9 @@ public override void Up() } var minimumAgeToPurchaseColumnName = nameof(Product.MinimumAgeToPurchase); - if (!Schema.Table(productTableName).Column(minimumAgeToPurchaseColumnName).Exists()) + if (!Schema.TableFor().Column(minimumAgeToPurchaseColumnName).Exists()) { - Alter.Table(productTableName) + Alter.TableFor() .AddColumn(minimumAgeToPurchaseColumnName) .AsInt32() .NotNullable() @@ -42,62 +40,59 @@ public override void Up() var topicAvailableEndDateColumnName = nameof(Topic.AvailableEndDateTimeUtc); var topicAvailableStartDateColumnName = nameof(Topic.AvailableStartDateTimeUtc); - if (!Schema.Table(topicTableName).Column(topicAvailableEndDateColumnName).Exists()) + if (!Schema.TableFor().Column(topicAvailableEndDateColumnName).Exists()) { - Alter.Table(topicTableName) + Alter.TableFor() .AddColumn(topicAvailableEndDateColumnName) .AsDateTime() .Nullable(); } - if (!Schema.Table(topicTableName).Column(topicAvailableStartDateColumnName).Exists()) + if (!Schema.TableFor().Column(topicAvailableStartDateColumnName).Exists()) { - Alter.Table(topicTableName) + Alter.TableFor() .AddColumn(topicAvailableStartDateColumnName) .AsDateTime() .Nullable(); } //#873 - var productTagTableName = nameof(ProductTag); - if (!Schema.Table(productTagTableName).Column(nameof(ProductTag.MetaDescription)).Exists()) - Alter.Table(productTagTableName).AddColumn(nameof(ProductTag.MetaDescription)).AsString().Nullable(); + if (!Schema.TableFor().Column(nameof(ProductTag.MetaDescription)).Exists()) + Alter.TableFor().AddColumn(nameof(ProductTag.MetaDescription)).AsString().Nullable(); - if (!Schema.Table(productTagTableName).Column(nameof(ProductTag.MetaKeywords)).Exists()) - Alter.Table(productTagTableName).AddColumn(nameof(ProductTag.MetaKeywords)).AsString(400).Nullable(); + if (!Schema.TableFor().Column(nameof(ProductTag.MetaKeywords)).Exists()) + Alter.TableFor().AddColumn(nameof(ProductTag.MetaKeywords)).AsString(400).Nullable(); - if (!Schema.Table(productTagTableName).Column(nameof(ProductTag.MetaTitle)).Exists()) - Alter.Table(productTagTableName).AddColumn(nameof(ProductTag.MetaTitle)).AsString(400).Nullable(); + if (!Schema.TableFor().Column(nameof(ProductTag.MetaTitle)).Exists()) + Alter.TableFor().AddColumn(nameof(ProductTag.MetaTitle)).AsString(400).Nullable(); //#7390 - if (!Schema.Table(nameof(Menu)).Exists()) + if (!Schema.TableFor().Exists()) Create.TableFor(); - if (!Schema.Table(nameof(MenuItem)).Exists()) + if (!Schema.TableFor().Exists()) Create.TableFor(); var footerColumn1ColumnName = "IncludeInFooterColumn1"; - if (Schema.Table(topicTableName).Column(footerColumn1ColumnName).Exists()) + if (Schema.TableFor().Column(footerColumn1ColumnName).Exists()) Delete.Column(footerColumn1ColumnName).FromTable(topicTableName); var footerColumn2ColumnName = "IncludeInFooterColumn2"; - if (Schema.Table(topicTableName).Column(footerColumn2ColumnName).Exists()) + if (Schema.TableFor().Column(footerColumn2ColumnName).Exists()) Delete.Column(footerColumn2ColumnName).FromTable(topicTableName); var footerColumn3ColumnName = "IncludeInFooterColumn3"; - if (Schema.Table(topicTableName).Column(footerColumn3ColumnName).Exists()) + if (Schema.TableFor().Column(footerColumn3ColumnName).Exists()) Delete.Column(footerColumn3ColumnName).FromTable(topicTableName); var includeTopicInTopMenuColumnName = "IncludeInTopMenu"; - if (Schema.Table(topicTableName).Column(includeTopicInTopMenuColumnName).Exists()) + if (Schema.TableFor().Column(includeTopicInTopMenuColumnName).Exists()) Delete.Column(includeTopicInTopMenuColumnName).FromTable(topicTableName); var categoryTableName = nameof(Category); var includeCategoryInTopMenuColumnName = "IncludeInTopMenu"; - if (Schema.Table(categoryTableName).Column(includeCategoryInTopMenuColumnName).Exists()) + if (Schema.TableFor().Column(includeCategoryInTopMenuColumnName).Exists()) Delete.Column(includeCategoryInTopMenuColumnName).FromTable(categoryTableName); - - } } From c218904d19011955af48b20a7da53bdb9facbffc Mon Sep 17 00:00:00 2001 From: Atiqur Rahman Foyshal Date: Thu, 20 Nov 2025 15:00:37 +0600 Subject: [PATCH 2/4] Add support for AddColumnFor, FromTable --- .../Extensions/FluentMigratorExtensions.cs | 31 +++++++++- .../UpgradeTo490/SchemaMigration.cs | 59 +++++++++++-------- 2 files changed, 63 insertions(+), 27 deletions(-) diff --git a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs index bbede67a9c6..dfa16446135 100644 --- a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs +++ b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs @@ -1,12 +1,16 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Data; +using System.Linq.Expressions; using System.Reflection; +using FluentMigrator.Builders; using FluentMigrator.Builders.Alter; using FluentMigrator.Builders.Alter.Table; using FluentMigrator.Builders.Create; using FluentMigrator.Builders.Create.Table; using FluentMigrator.Builders.Delete; +using FluentMigrator.Builders.Delete.Column; using FluentMigrator.Builders.Schema; +using FluentMigrator.Builders.Schema.Column; using FluentMigrator.Builders.Schema.Table; using FluentMigrator.Infrastructure.Extensions; using FluentMigrator.Model; @@ -172,16 +176,39 @@ public static IAlterTableAddColumnOrAlterColumnOrSchemaOrDescriptionSyntax Table } /// - /// Retrieves expressions into IAlterExpressionRoot + /// Retrieves expressions into ISchemaExpressionRoot /// /// The root expression for a SCHEMA /// Entity type - public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot schema) + public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot schema) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); return schema.Table(tableName); } + public static ISchemaColumnSyntax ColumnFor( + this ISchemaTableSyntax schema, Expression> selector) where TEntity : BaseEntity + { + var property = ((MemberExpression)selector.Body)?.Member?.Name; + var columnName = NameCompatibilityManager.GetColumnName(typeof(TEntity), property!); + return schema.Column(columnName); + } + + public static IAlterTableColumnAsTypeSyntax AddColumnFor( + this IAlterTableAddColumnOrAlterColumnSyntax tableSchema, Expression> selector) where TEntity : BaseEntity + { + var property = ((MemberExpression)selector.Body)?.Member?.Name; + var columnName = NameCompatibilityManager.GetColumnName(typeof(TEntity), property!); + return tableSchema.AddColumn(columnName); + } + + public static IInSchemaSyntax FromTable( + this IDeleteColumnFromTableSyntax tableSchema) where TEntity : BaseEntity + { + var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); + return tableSchema.FromTable(tableName); + } + /// /// Retrieves expressions for building an entity table /// diff --git a/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs b/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs index 6cbd40d17a5..ab78faf6cd8 100644 --- a/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs +++ b/src/Libraries/Nop.Data/Migrations/UpgradeTo490/SchemaMigration.cs @@ -15,57 +15,67 @@ public class SchemaMigration : ForwardOnlyMigration public override void Up() { //#7387 - var ageVerificationColumnName = nameof(Product.AgeVerification); - if (!Schema.TableFor().Column(ageVerificationColumnName).Exists()) + if (!Schema.TableFor().ColumnFor(t => t.AgeVerification).Exists()) { Alter.TableFor() - .AddColumn(ageVerificationColumnName) + .AddColumnFor(t => t.AgeVerification) .AsBoolean() .NotNullable() .WithDefaultValue(false); } - var minimumAgeToPurchaseColumnName = nameof(Product.MinimumAgeToPurchase); - if (!Schema.TableFor().Column(minimumAgeToPurchaseColumnName).Exists()) + if (!Schema.TableFor().ColumnFor(t => t.MinimumAgeToPurchase).Exists()) { Alter.TableFor() - .AddColumn(minimumAgeToPurchaseColumnName) + .AddColumnFor(t => t.MinimumAgeToPurchase) .AsInt32() .NotNullable() .WithDefaultValue(0); } //#7294 - var topicTableName = nameof(Topic); - var topicAvailableEndDateColumnName = nameof(Topic.AvailableEndDateTimeUtc); - var topicAvailableStartDateColumnName = nameof(Topic.AvailableStartDateTimeUtc); - if (!Schema.TableFor().Column(topicAvailableEndDateColumnName).Exists()) + if (!Schema.TableFor().ColumnFor(t => t.AvailableEndDateTimeUtc).Exists()) { Alter.TableFor() - .AddColumn(topicAvailableEndDateColumnName) + .AddColumnFor(t => t.AvailableEndDateTimeUtc) .AsDateTime() .Nullable(); } - if (!Schema.TableFor().Column(topicAvailableStartDateColumnName).Exists()) + if (!Schema.TableFor().ColumnFor(t => t.AvailableStartDateTimeUtc).Exists()) { Alter.TableFor() - .AddColumn(topicAvailableStartDateColumnName) + .AddColumnFor(t => t.AvailableStartDateTimeUtc) .AsDateTime() .Nullable(); } //#873 - if (!Schema.TableFor().Column(nameof(ProductTag.MetaDescription)).Exists()) - Alter.TableFor().AddColumn(nameof(ProductTag.MetaDescription)).AsString().Nullable(); + if (!Schema.TableFor().ColumnFor(t => t.MetaDescription).Exists()) + { + Alter.TableFor() + .AddColumnFor(t => t.MetaDescription) + .AsString() + .Nullable(); + } - if (!Schema.TableFor().Column(nameof(ProductTag.MetaKeywords)).Exists()) - Alter.TableFor().AddColumn(nameof(ProductTag.MetaKeywords)).AsString(400).Nullable(); + if (!Schema.TableFor().ColumnFor(t => t.MetaKeywords).Exists()) + { + Alter.TableFor() + .AddColumnFor(t => t.MetaKeywords) + .AsString(400) + .Nullable(); + } - if (!Schema.TableFor().Column(nameof(ProductTag.MetaTitle)).Exists()) - Alter.TableFor().AddColumn(nameof(ProductTag.MetaTitle)).AsString(400).Nullable(); + if (!Schema.TableFor().ColumnFor(t => t.MetaTitle).Exists()) + { + Alter.TableFor() + .AddColumnFor(t => t.MetaTitle) + .AsString(400) + .Nullable(); + } //#7390 if (!Schema.TableFor().Exists()) @@ -76,23 +86,22 @@ public override void Up() var footerColumn1ColumnName = "IncludeInFooterColumn1"; if (Schema.TableFor().Column(footerColumn1ColumnName).Exists()) - Delete.Column(footerColumn1ColumnName).FromTable(topicTableName); + Delete.Column(footerColumn1ColumnName).FromTable(); var footerColumn2ColumnName = "IncludeInFooterColumn2"; if (Schema.TableFor().Column(footerColumn2ColumnName).Exists()) - Delete.Column(footerColumn2ColumnName).FromTable(topicTableName); + Delete.Column(footerColumn2ColumnName).FromTable(); var footerColumn3ColumnName = "IncludeInFooterColumn3"; if (Schema.TableFor().Column(footerColumn3ColumnName).Exists()) - Delete.Column(footerColumn3ColumnName).FromTable(topicTableName); + Delete.Column(footerColumn3ColumnName).FromTable(); var includeTopicInTopMenuColumnName = "IncludeInTopMenu"; if (Schema.TableFor().Column(includeTopicInTopMenuColumnName).Exists()) - Delete.Column(includeTopicInTopMenuColumnName).FromTable(topicTableName); + Delete.Column(includeTopicInTopMenuColumnName).FromTable(); - var categoryTableName = nameof(Category); var includeCategoryInTopMenuColumnName = "IncludeInTopMenu"; if (Schema.TableFor().Column(includeCategoryInTopMenuColumnName).Exists()) - Delete.Column(includeCategoryInTopMenuColumnName).FromTable(categoryTableName); + Delete.Column(includeCategoryInTopMenuColumnName).FromTable(); } } From 325c3649dd68f5b24afe4a69380eab7e0c997333 Mon Sep 17 00:00:00 2001 From: Atiqur Rahman Foyshal Date: Thu, 20 Nov 2025 15:39:42 +0600 Subject: [PATCH 3/4] add summary --- .../Extensions/FluentMigratorExtensions.cs | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs index dfa16446135..aa32610de37 100644 --- a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs +++ b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs @@ -154,10 +154,10 @@ public static void TableFor(this ICreateExpressionRoot expressionRoot) } /// - /// Retrieves expressions into IDeleteExpressionRoot + /// Targets the entity's mapped table for a DELETE operation. /// /// The root expression for a DELETE operation - /// Entity type + /// The entity type mapped to the database table public static void TableFor(this IDeleteExpressionRoot expressionRoot) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); @@ -165,10 +165,14 @@ public static void TableFor(this IDeleteExpressionRoot expressionRoot) } /// - /// Retrieves expressions into IAlterExpressionRoot + /// Targets the entity's mapped table for an ALTER TABLE operation. /// - /// The root expression for a ALTER operation - /// Entity type + /// The root expression for an ALTER operation + /// The entity type mapped to the database table + /// + /// A fluent syntax interface allowing further ALTER TABLE operations + /// such as adding or modifying columns. + /// public static IAlterTableAddColumnOrAlterColumnOrSchemaOrDescriptionSyntax TableFor(this IAlterExpressionRoot expressionRoot) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); @@ -176,16 +180,31 @@ public static IAlterTableAddColumnOrAlterColumnOrSchemaOrDescriptionSyntax Table } /// - /// Retrieves expressions into ISchemaExpressionRoot + /// Targets the entity's mapped table for schema-related operations. /// - /// The root expression for a SCHEMA - /// Entity type + /// The root expression for schema inspection + /// The entity type mapped to the database table + /// + /// A fluent syntax interface for performing schema operations + /// such as checking table or column existence. + /// public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot schema) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); return schema.Table(tableName); } + /// + /// Targets a specific column of the entity's mapped table for schema inspection, + /// resolving the column name via . + /// + /// The entity type mapped to the database table + /// The schema table expression + /// An expression selecting the entity property + /// + /// A fluent syntax interface for performing schema operations + /// such as checking column existence. + /// public static ISchemaColumnSyntax ColumnFor( this ISchemaTableSyntax schema, Expression> selector) where TEntity : BaseEntity { @@ -194,6 +213,17 @@ public static ISchemaColumnSyntax ColumnFor( return schema.Column(columnName); } + /// + /// Adds a new column to the entity's mapped table for ALTER TABLE operations, + /// resolving the column name via . + /// + /// The entity type mapped to the database table + /// The alter table expression + /// An expression selecting the entity property + /// + /// A fluent syntax interface allowing further ALTER TABLE operations + /// on the specified column. + /// public static IAlterTableColumnAsTypeSyntax AddColumnFor( this IAlterTableAddColumnOrAlterColumnSyntax tableSchema, Expression> selector) where TEntity : BaseEntity { @@ -202,6 +232,15 @@ public static IAlterTableColumnAsTypeSyntax AddColumnFor( return tableSchema.AddColumn(columnName); } + /// + /// Targets the mapped table of the specified entity for a DELETE COLUMN operation, + /// resolving the table name via . + /// + /// The entity type mapped to the database table + /// The delete column from table syntax + /// + /// A fluent syntax interface allowing the deletion of columns from the specified table. + /// public static IInSchemaSyntax FromTable( this IDeleteColumnFromTableSyntax tableSchema) where TEntity : BaseEntity { From 3da30624884cc12d94569ad3ba3d78978cc6ef6b Mon Sep 17 00:00:00 2001 From: Atiqur Rahman Foyshal Date: Thu, 20 Nov 2025 16:47:03 +0600 Subject: [PATCH 4/4] refactor variable naming --- .../Extensions/FluentMigratorExtensions.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs index aa32610de37..ea2bbfcb572 100644 --- a/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs +++ b/src/Libraries/Nop.Data/Extensions/FluentMigratorExtensions.cs @@ -182,16 +182,16 @@ public static IAlterTableAddColumnOrAlterColumnOrSchemaOrDescriptionSyntax Table /// /// Targets the entity's mapped table for schema-related operations. /// - /// The root expression for schema inspection + /// The root expression for schema inspection /// The entity type mapped to the database table /// /// A fluent syntax interface for performing schema operations /// such as checking table or column existence. /// - public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot schema) where TEntity : BaseEntity + public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot expressionRoot) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); - return schema.Table(tableName); + return expressionRoot.Table(tableName); } /// @@ -199,18 +199,18 @@ public static ISchemaTableSyntax TableFor(this ISchemaExpressionRoot sc /// resolving the column name via . /// /// The entity type mapped to the database table - /// The schema table expression + /// The schema table expression /// An expression selecting the entity property /// /// A fluent syntax interface for performing schema operations /// such as checking column existence. /// public static ISchemaColumnSyntax ColumnFor( - this ISchemaTableSyntax schema, Expression> selector) where TEntity : BaseEntity + this ISchemaTableSyntax tableSchema, Expression> selector) where TEntity : BaseEntity { var property = ((MemberExpression)selector.Body)?.Member?.Name; var columnName = NameCompatibilityManager.GetColumnName(typeof(TEntity), property!); - return schema.Column(columnName); + return tableSchema.Column(columnName); } /// @@ -237,15 +237,15 @@ public static IAlterTableColumnAsTypeSyntax AddColumnFor( /// resolving the table name via . /// /// The entity type mapped to the database table - /// The delete column from table syntax + /// The delete column expression from table syntax /// /// A fluent syntax interface allowing the deletion of columns from the specified table. /// public static IInSchemaSyntax FromTable( - this IDeleteColumnFromTableSyntax tableSchema) where TEntity : BaseEntity + this IDeleteColumnFromTableSyntax expressionRoot) where TEntity : BaseEntity { var tableName = NameCompatibilityManager.GetTableName(typeof(TEntity)); - return tableSchema.FromTable(tableName); + return expressionRoot.FromTable(tableName); } ///