Dynamic data does not display calculated fields; ASP.NET 4.5, Entity Framework 5.0

I am trying to display calculated fields on my Dynamic Data Entities site. I created my EDMX file from an existing database and added the settings to a separate file using partial classes. I want the computed fields to be displayed on the display and list screens.

I have seen many examples online where people may work this way; however, most of them focus on Code-First approaches instead of Database-First. I do not have the Code-First option since the database is already completed.

I have tried various data annotations, including:

[ScaffoldColumn(true)]
[NotMapped]
[ReadOnly]
[Display(AutoGenerateField=true)]

I also tried using MetadataType in the following format:

[MetadataType(typeof(ProductMetadata))]
public partial class Product
{
    [ScaffoldColumn(true)]
    [NotMapped]
    public decimal CostPerUnit
    {
        get
        {
           return TotalCost / (decimal)TotalUnits;
        }
    }
}

public class ProductMetadata
{
    [ReadOnly(true)]
    [Display(Name = "[Cost Per Page]", AutoGenerateField = true, AutoGenerateFilter = false)]
    [UIHint("Number")]
    public object CostPerUnit { get; set; }
}

. Product, ( ), . . .

- , ? EntityFramework 5.0 ? , EF 6.0 , ?

2014-07-11:

Entity Framework 6 -. , .

- - ? 100% ( ).

+4

Source: https://habr.com/ru/post/1547457/


All Articles