I have the following enum:
namespace Common
{
public enum VehicleType
{
Car=10,
Bike=20
}
}
I have created a reference enum type in EF designer with the name VehicleType
referencing Common.VehicleType. The edmx is in the Models
namespace so i end up with two different enums:
Common.VehicleType
Models.VehicleType
To set the enum on an entity object instance i need to cast it:
Vehicle vehicle = new Vehicle();
vehicle.VehicleType = (Models.VehicleType)Common.VehicleType.Bike;
There are a couple of problems with this:
- I need to use fully qualified names (the names of the enums must be the same from what i gather).
- I need to cast everywhere.
- I will get a circular reference since the
Models
namespace referencesCommon
andCommon
now needs to referenceModels
in order to cast.
This is a simplified explanation. I can't change the references or the generator template since that would amount to massive code changes in a quite large project.
I guess its the generation template screwing things up. Is there any way to get around this?
EDIT
Fields with type VehicleType generated by EntityObject template generator become:
private VehicleType _VehicleType;
where VehicleType is Models.VehicleType