I am using EF5 and .NET 4.5. I have one particular class that is being generated incorrectly in the database. Although it is somewhat more complicated in my website, I\'ll s
Based on the answer by Gert Amold you could create a nice wrapper class by using the implicit operator:
public class RoleWrapper
{
public int Id { get; set; }
// Role is any Enum
public Role Role { get; set; }
public static implicit operator Role(RoleWrapper val)
{
return val.Role;
}
public static implicit operator RoleWrapper(Role val)
{
return new RoleWrapper() { Role = val };
}
}
This way you can use the collection with the primitiv Enum type Role:
myUser.Roles.Add(Role.WhateverRole);
Role firstRole = myUser.Roles[0];