Reputation: 64933
This is about Entity Framework 5 RTM Code First.
When I map an entity having an existing enum I get this error:
No corresponding object layer type could be found for the conceptual type '[FULL ENUM TYPE NAME]'
Actually it looks for the whole enum in the same namespace of the DbContext
.
Some other question (Using Enums with Code First & Entity Framework 5) had an answer that pointed to some blog post where there's a how-to on how to get this working but it talks about Database-First/Model-First approach.
How can I add an EDM enum type using Code-First approach?
Upvotes: 1
Views: 1517
Reputation: 5489
I am afraid it isn't possible right now - there is known bug in the EF5 http://entityframework.codeplex.com/workitem/532, that is causing the mentioned error.
I was struggling with the similar problem and didn't find any elegant solution. I ended up with int
column instead of enum column.
Edit (problematic model):
Core assembly:
public enum UserStatus { Approved, Disabled }
public interface IUser {
public int ID { get; }
public string Username { get; set;}
public UserStatus Status { get; set;}
}
Users assembly:
public class User : IUser {
public int ID { get; protected set; }
public string Username { get; set; }
public UserStatus Status { get; set; }
}
Upvotes: 1