I have a model in another model. When I try to check the modelstate it is invalid. This is because the other model in this model is null.
Project.cs:
using System.ComponentModel.DataAnnotations;
namespace Toolbox.Models
{
public class Project
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public WorkPreparation WorkPreparation { get; set; }
}
}
WorkPreparation.cs:
using System.ComponentModel.DataAnnotations;
namespace Toolbox.Models
{
public class WorkPreparation
{
[Key]
public int Id { get; set; }
public int ProjectId { get; set; }
public CentralHeating CentralHeating { get; set; }
public Pluming Pluming { get; set; }
public Ventilation Ventilation { get; set; }
public Project Project { get; set; }
}
}
Does anybody have any suggestion?
