I know when working with model-first development, you can use partial classes generated by the t4 templates to add metadata. e.g.
public partial class Address
{
public int Id { get; set; }
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
Then in a separate file, I do:
[MetadataType(typeof(AddressMetadata))]
public partial class Address {
}
internal sealed class AddressMetadata {
[Display(Name = "Street")]
public string Street1 { get; set; }
[Display(Name = "Street (cont.)")]
public string Street2 { get; set; }
[Display(Name = "Zip code")]
public string Zip { get; set; }
}
I'm trying to do this for an enum type defined within the EDMX file.
// this doesn't work
[MetadataType(typeof(ContactTypeMetadata))]
public enum ContactType {
}
public class ContactTypeMetadata {
}
Doing this, I get the following error:
Error 1 The namespace 'Models' already contains a definition for 'ContactType'
Is there anyway to do the same functionality for the enumerations as you can do for the classes in a model-first project?
EDIT
Within the EDMX file, I've defined an enum type:
namespace WindowsFormsApplication1
{
using System;
public enum ContactType : int
{
CEO = 0,
CIO = 1,
Peasant = 2
}
}
I'm trying to find a way using a similar mechanism (in separate files so that if I modify the EDMX my changes won't get overwritten) to accomplish this:
namespace WindowsFormsApplication1
{
using System;
public enum ContactType : int
{
[Display(Name="Chief Executive Officer")]
CEO = 0,
[Display(Name="Chief Information Officer")]
CIO = 1,
[Display(Name="Regular Employee")]
Peasant = 2
}
}