views:

152

answers:

1

Using a very run-of-the-mill database, with identity int for primary keys, a Dynamic Data Entities Project (EntityFramework) displays the primary key for view and edit. When using Linq to Sql, the primary key fields are not displayed.

I would like to hide the primary keys and use Entity Framework (VS 2008, .Net 3.5 sp1). thanks

+2  A: 

Use ScaffoldColumnAttribute to not scaffold a column.

You'll need to either customize code generation (easier in EF 4) or use a buddy class for this.

[MetadataType(typeof(MyEntity_Metadata))]
public partial class MyEntity 
{
}

public class MyEntity_Metadata 
{
    [ScaffoldColumn(false)]
    public int Id { get; set; }
}
Craig Stuntz
There is a third option; wiring up your own convention based AssociatedMetadataTypeTypeDescriptionProvider. http://mattberseth.com/blog/2008/08/dynamic_data_and_custom_metada.html
jfar