The only solution I have found is to modify the FluentMigratorMedataReader.cs core file like this:
protected T GetAttribute<T>(Type type, MemberInfo memberInfo) where T : Attribute
{
var attribute = Types.GetOrAdd((type, memberInfo), t =>
{
var tableExpr = Expressions.GetOrAdd(type, entityType => _migrationManager.GetCreateTableExpression(entityType));
if (typeof(T) == typeof(TableAttribute))
return new TableAttribute(tableExpr.TableName) { Schema = tableExpr.SchemaName };
if (typeof(T) != typeof(ColumnAttribute))
return null;
var column = tableExpr.Columns.SingleOrDefault(cd => cd.Name.Equals(NameCompatibilityManager.GetColumnName(type, memberInfo.Name), StringComparison.OrdinalIgnoreCase));
if (column is null)
return null;
// Modification to exclude properties with the NotMapped or NotColumn attribute
if (memberInfo.CustomAttributes.Any(a => a.AttributeType == typeof(NotMappedAttribute)))
return null;
if (memberInfo.CustomAttributes.Any(a => a.AttributeType == typeof(NotColumnAttribute)))
return null;
return new ColumnAttribute
{
Name = column.Name,
IsPrimaryKey = column.IsPrimaryKey,
IsColumn = true,
CanBeNull = column.IsNullable ?? false,
Length = column.Size ?? 0,
Precision = column.Precision ?? 0,
IsIdentity = column.IsIdentity,
DataType = new SqlDataType((memberInfo as PropertyInfo)?.PropertyType ?? typeof(string)).DataType
};
});
return (T)attribute;
}
Is there a proper way to achieve this without modifying the core nop files, the model classes, or the database?