Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert to Enum

I just got Visual-Studio 2012 Professional and am using the Entity-Framework (5.0) designer. I've been trying to convert a property to an Enum, and according to this Microsoft video I right click the property and choose Convert to Enum at (2:06) - there is no option for converting in my context menu.

Here I'm trying to convert Role to Enum. I've set Role to be an Int32.

enter image description here

What am I doing wrong?

like image 489
Chuck Savage Avatar asked Nov 19 '12 15:11

Chuck Savage


2 Answers

Following the video in the post closely, I opened the Model Browser to add an Enum manually. After I had done so, and set the Role to the enum I had created. To test if I could now Convert To Enum on the property, I changed the type back to Int32 and then right clicked the property and and low and behold I see the Convert To Enum option in the context menu!

So, if your having problems these are the steps I used to enable the Convert To Enum option. This is a hack in my opinion, as now I cannot reproduce this behavior with a new solution and project. Apparently once the Model Browser has been opened for the first time (or the complete steps below) it now shows the Convert To Enum option.

-1. Using the Quick Launch search window, I typed in Model Browser and opened it up.

Model Browser search

-2. Choose Add New Enum Type... from right clicking Enum Types in the Model Browser for your Data Model.

enter image description here

-3. Set your property to the enum, scroll to the bottom of the listed types in the combo-box and choose the enum.

like image 78
Chuck Savage Avatar answered Sep 23 '22 18:09

Chuck Savage


i had this problem too!! i changed entity framework from 4 to 4.5 and problem solved! ;)

like image 20
saman hossaini Avatar answered Sep 20 '22 18:09

saman hossaini