I've created a new web site based on the 'Dynamic Data Site' template. Three tables were added into it: Product, ProductSKU, and SkuPrice. There are relationships between tables:
Product.ProdId = ProductSku.ProdId
ProductSku.SkuId = SkuPrice.SkuId
I don't want the user to see 'Product' table, so I've hidden that table:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductMetadata))]
public partial class Product
{
}
[ScaffoldTable(false)]
public class ProductMetadata
{
}
}
When I tried to hide some columns in the 'ProductSKU' table:
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
I've discovered that didn't work: the column is still displayed. The problem seems like the 'ProductSKU' class is not 'matched' to existing table...
Here is auto-generated code for that table:
namespace CompanyDbAdmin
{
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmEntityTypeAttribute(NamespaceName="SotiModel", Name="ProductSKU")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class ProductSKU : EntityObject
{
....
}
}
Attempt to hide this table with
namespace CompanyDbAdmin
{
[MetadataType(typeof(ProductSKUMetadata))]
public partial class ProductSKU
{
}
[ScaffoldTable(false)]
public class ProductSKUMetadata
{
[ScaffoldColumn(false)]
public object MyCollumnName { get; set; }
}
}
Doesn't work either: The table still exists on the first page...
Why? How can I fix that?
The solution to that question: Partial class doesn't match to auto-generated class part resolved the current one either
The problem was in in Visual Studio: it didn't consider the entity class as a partial class... And as a result, it didn't apply metadataclass to the entity class.