EntityFramework and Enums
Hi everyone, I have been using EF a lot recently. I typically go DB first because it's just what I'm comfortable with.
I feel pretty comfortable with most of the features but I'm still a bit unsure of how to properly use Enums.
Example schema:
Ticket
| Column | Type | Constraint |
|---|---|---|
| Id | Guid | PRIMARY KEY |
| Description | NVARCHAR(250) | |
| StatusId | INT | FOREIGN KEY REFERENCES [Status](Id) |
Status
| Column | Type | Constraint |
|---|---|---|
| Id | INT | PRIMARY KEY |
| Name | NVARCHAR(50) |
Status has three records, 1:Submitted, 2:Accepted, and 3:Complete
Can EF map those values to an Enum somehow? I see the "Convert to Enum" when I right click the "StatusId" property but I'm not certain how that works out for mapping Enum values to DB values.
Am I supposed to not import the reference/lookup table and just ensure that my seeds stay synced up properly?
0 comments:
Post a Comment