Social Icons

Handling Enum in Code First Entity Framework4.1

Hi All,
EF Code first approach has been developing(03-12-2012) and in version 4.1 it does not support mapping enum typed properties to database. You can find a few workarounds for that on the web. Each solution has its pros and cons, and I would like to present one, which is in my opinion easiest (in sense of coding effort) and most extensible.

1st lets create enum;

Then lets create LeaveStatusWrapper class as follows;

Lets create Leave class;

then need to define data base context class as;

We can write a test class for test this scenario as follows;

Enjoy !!!

No comments:

Post a Comment