3
클래스와 속성이 있습니다. 나는 Entity Framework를 MySQL과 함께 사용하고 있습니다. add-migration
을 사용하여 마이그레이션 한 후 INT(11)
열을 생성합니다. 하지만 VARCHAR
이 필요합니다. 부서 또는 학점이 필요하기 때문입니다.Entity Framework에서 문자열 열거 형
많이 시도했지만 시도하지 않았습니다.
어떻게하면됩니까?
public class trns
{
public trans_type enm_trans_type { get; set; }
}
public enum trans_type {
[Description("Dept")]
Dept,
[Description("Credit")]
Credit
}
CodeFirst를 사용하면 다음과 같은 버전이 필요합니다. http://stackoverflow.com/questions/7437952/map-string-column-in-entity-framework-to-enum 좋은 기사 http://nodogmablog.bryanhogan.net/2014/11/saving-enums-as-strings-with-entity-framework/ –
네, 맞습니다. http://nodogmablog.bryanhogan.net/2014/11/saving-enums-as-strings-with-entity-framework/ – caras