4

I have a class, and properties like. I am using Entity Framework with Mysql. After migration using add-migration, it will create an INT(11) column. But I need VARCHAR because, I need Dept or Credit value.

I tried a lot, but it didn't.

How can I do?

public class trns
{
     public trans_type enm_trans_type { get; set; } 
}

 public enum trans_type {
    [Description("Dept")]
    Dept,
    [Description("Credit")]
    Credit   
 }
2

1 Answer 1

1

Your enumeration is based on an integral value and EF will create an int column behind the scene to store the value of the enum. It is better to store the int value of enumn in database instead of its description and use lookup tables. Then you can simply get description of them using a single join. You can use ef-enum-to-lookup by Tim Abell.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.