I am working with Entity Framework Code first. I have a simple model:
public class Variable
{
public string Name { get; set; }
public int Id { get;
No, EF doesn't have any type converters or custom type mappers as alternative to model binders from MVC. You must always use some hack to force persistence. Another way to do the same is mapping TextOptions
as collection of related entities. It will make your separation of concerns better but it will complicate your model and working with Variable
.
public class Variable
{
public string Name { get; set; }
public int Id { get; set; }
public IList TextOptions
{
get;
set;
}
}
public class TextOption
{
public int Id { get; set; }
public string Text { get; set; }
}