Mr_Hmp
Mr_Hmp

Reputation: 2535

How to convert database table entry to an enum?

In my web application I have many tables which have fixed data, when I use them in my project then I use enums for that purpose.

I want to convert these tables to enums automatically.

After little looking up I did this by using T4, TextTemplates: see my code here.

But I wanted to do this by using Entity Framework, according to the official documentation enums are supported in .NET Framework 4.5 and above, but I am using .NET 3.5.

How can I achieve this, potentially by using custom text templates?

Upvotes: 2

Views: 653

Answers (1)

Mr_Hmp
Mr_Hmp

Reputation: 2535

So I finally solved it. Made a T4 template and replaced that with the default generated tt file.

My code is here, please star it if you found it helpful and add comments in case of help or suggestions.

Upvotes: 1

Related Questions