efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Some IEntity metadata properties return null values

Open JuanIrigoyen opened this issue 10 years ago • 1 comments

Steps to reproduce

IProperty property = ientityType.FindProperty(propertyName); if (property == null) return null;

int? maxlenght; if (property.GetMaxLength().HasValue) { maxlenght = property.GetMaxLength(); }

string entityFullName = string.Format(CultureInfo.CurrentCulture, "{0}.{1}", ientityType.SqlServer().Schema, ientityType.SqlServer().TableName);

The issue

The method property.GetMaxLength() of IEntityType return null sometimes and the property.GetMaxLength().HasValue return false, but the property.SqlServer().ColumnType return 'Maxlenth(4)'

The property ientityType.SqlServer().Schema return null value if schema is dbo

Further technical details

EF Core version 1 Operating system: Windows 10 Visual Studio version: (e.g. VS 2015 or n/a)

JuanIrigoyen avatar Jul 04 '16 14:07 JuanIrigoyen

@JuanIrigoyen GetMaxLength only returns a value if it has been set directly. EF does not currently extract values from relational-specific type mappings and use them to populate the core metadata MaxLength.

ajcvickers avatar Jul 05 '16 16:07 ajcvickers