Entity Framework and Database Column Names

I am trying to modify the POCO T4 template to include a column name in the database corresponding to each property. For outdated reasons, our database tables are 8.3 and our columns are no more than 10 characters, so things tend to be despised. Perhaps quickly finding which column corresponds to this property would be a big help.

Given this, I have no idea how to do this. I like the idea of ​​editing a T4 template, I just don't know how to get the column name from the EdmProperty object.

Can someone point me in the right direction?

+5
source share
2 answers

- , . , MSL - , . , API MSL ( , EF - ). T4 , CSDL - , EDMX .

+1

, , . BoundField asp, EF.

, , " ", , . "table" "ColumnNames" .

<#
    if (simpleProperties.Any())
    {
#>
    public struct ColumnName 
    {
  <# 
      foreach (var simpleProperty in simpleProperties)
      {
  #>
      public const string <#= simpleProperty #> = "<#= simpleProperty #>";
  <# 
      }
  #>
  }
<#  }
#>
}

T4, edmx :

<#
    EndNamespace(code);
}

, :

public partial class JobPosting
{
    public int PositionRowId { get; set; }
    public System.Guid PositionRelatedGuid { get; set; }

    public struct ColumnName 
    {
        public const string PositionRowId = "PositionRowId";
        public const string PositionRelatedGuid = "PositionRelatedGuid";
    }
}

, .

0

All Articles