How to use Enum with Entityframework

Asked

Viewed 192 times

0

I have a relationship in my system where one class has a relationship with another, but this other class is nowhere in the system to change/delete its state (are only static data).

I wonder if the ideal for that would be to use Enum and how I use enums on C# using Entityframework?

Enum has the following structure:

inserir a descrição da imagem aqui

I would like to make this be reflected in the database in table form and already filled (Since the user will not be able to modify anything of this table)

  • Represent this in a common model and a table in your database ...! I think it’s best

  • 1

    As Linq replied, it is not possible to represent Num directly at the bank, you need a class. But I understand your need and I had a similar one. This solution solved for me: https://stackoverflow.com/a/34558339/4713574 . I hope it helps. If necessary, the night I see the code the way I used and share

  • 1

    Okay @Rovannlinhalis, thank you so much for your attention, I’m on hold!

  • @Renannarciso I put as answer to the question that generated duplicity. I hope it helps: https://answall.com/a/277972/69359

1 answer

0


Not possible. In Entity Framework types by value cannot represent a table.

  • Well, seeing the topic you referred to, then it is understood that an Enum cannot be reflected in the database and turn a table, but I can use my Num in a Model, correct?

  • 1

    @Renannarciso That

  • https://stackoverflow.com/a/34558339/4713574

  • 1

    It’s still not possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.