Reputation:
I'm using Entity Framework edmx. When I update the edmx I lose my metadata.How do you create and use metadata properties (that are not real fields).
Upvotes: 2
Views: 848
Reputation:
Create a Metadata folder in the project where is the edmx. Create a class with the name of your entity as bellow: And within the same file create another class with the name of your entity with the "metadata" extension (MyEntityMetadata).
namespace MyNameSpace.DataAccess //You need to use the same namespace of edmx entities files
{
[MetadataType(typeof(MyEntityMetaData))]
public partial class MyEntity //This is possible because entities files using partial class
{
[NotMapped] //System.ComponentModel.DataAnnotations.Schema
public int MyProperty { get; set; }
//more properties...
}
public class UsuarioMetaData
{
[Display(ResourceType = typeof(Resources.Global), Name = "MyFieldLabel")]
public int MyField { get; set; }
//More fields
}
}
Upvotes: 1