Asp.net mvc 视图中存在的必填字段将始终使model.state为false

Asp.net mvc 视图中存在的必填字段将始终使model.state为false,asp.net-mvc,Asp.net Mvc,我有以下模型类:- public class TMSServer_Validation { [Required] public string ILOIP { get; set; } } public class ServerJoin { public TMSServer Server { get; set; } public Resource Resource { get; set; } public Technology Technology { ge

我有以下模型类:-

public class TMSServer_Validation
{
    [Required]
    public string ILOIP { get; set; }
}
public class ServerJoin
{
    public TMSServer Server { get; set; }
    public Resource Resource { get; set; }
    public Technology Technology { get; set; }
    public ComponentDefinition ComponentDefinition { get; set; }
}
以及以下观点:-

@model TMS.ViewModels.ServerJoin
<div >
  <span class="f">  ILOIP</span>

    @Html.EditorFor(model =>model.Server.ILOIP)
    @Html.ValidationMessageFor(model =>model.Server.ILOIP)
</div>
以及以下视图模型类:-

public class TMSServer_Validation
{
    [Required]
    public string ILOIP { get; set; }
}
public class ServerJoin
{
    public TMSServer Server { get; set; }
    public Resource Resource { get; set; }
    public Technology Technology { get; set; }
    public ComponentDefinition ComponentDefinition { get; set; }
}
但是每当我想要编辑一个对象时,模型状态将为False,并且错误消息指示需要ILOP字段,尽管视图上有一个值

那么是什么导致了这个问题呢

更新

Th型号等级为:-

[MetadataType(typeof(TMSServer_Validation))]     
public partial class TMSServer
        {
            public TMSServer()
            {
                this.TMSServers1 = new HashSet<TMSServer>();
                this.TMSVirtualMachines = new HashSet<TMSVirtualMachine>();
            }

            public int ServerID { get; set; }
            public Nullable<int> ServerModelID { get; set; }
            public int DataCenterID { get; set; }
            public string ILOIP { get; set; }
            public int RackID { get; set; }
            public Nullable<int> StatusID { get; set; }
            public Nullable<int> BackUpStatusID { get; set; }
            public int RoleID { get; set; }
            public Nullable<int> OperatingSystemID { get; set; }
            public Nullable<int> VirtualCenterID { get; set; }
            public string Comment { get; set; }
            public byte[] timestamp { get; set; }
            public long IT360SiteID { get; set; }

            public virtual DataCenter DataCenter { get; set; }
            public virtual OperatingSystem OperatingSystem { get; set; }
            public virtual ServerModel ServerModel { get; set; }
            public virtual Technology Technology { get; set; }
            public virtual TechnologyBackUpStatu TechnologyBackUpStatu { get; set; }
            public virtual TechnologyRole TechnologyRole { get; set; }
            public virtual TechnologyStatu TechnologyStatu { get; set; }
            public virtual TMSRack TMSRack { get; set; }
            public virtual ICollection<TMSServer> TMSServers1 { get; set; }
            public virtual TMSServer TMSServer1 { get; set; }
            public virtual ICollection<TMSVirtualMachine> TMSVirtualMachines { get; set; }
        }

为什么您的类称为TMSServer\u Validation,但视图模型中称为TMSServer?因为它是TMSServer的MetadataType类。那么,您可以发布模型类吗?您可以检查我的更新吗?您可以在FormCollection formValues中看到ILOIP的值吗?顺便问一下,你在这里发布的模型类是EF自动生成的吗?