An error occurred during the compilation of a resource required to service this request / Models

1

Hi, I made some changes to this table in my database and now I'm having problems with my data model. Trying to get my data I got the following error. I understand that the error is in data model, now I must change it to be similar to my new table. From this I have come up with a series of questions regarding the data model. They are the following:

  • Should my model contain the data equivalent that rows in my Sql table?
  • Can I use less data in my model?
  • What is the correct data type to reference a varbinary in my model?

Here I leave my previous data model and if you could recommend me some changes to make this work, it would be great. Thank you very much: D

using System.ComponentModel.DataAnnotations;

namespace PCotiza_compras.Models {
  public class Requests {
    public int Id {
      get;
      set;
    }
    public string Wiw {
      get;
      set;
    }


    [Display(Name = "Proyecto")]
    public string Project {
      get;
      set;
    }

    [Display(Name = "Esquema")]
    public int schemeid {
      get;
      set;
    }

    [Display(Name = "Fecha")]
    public string Date {
      get;
      set;
    }

    [Display(Name = "Estado")]
    public string status {
      get;
      set;
    }

    [Display(Name = "Días de expiración")]
    public int ExpirationDays {
      get;
      set;
    }

    [Display(Name = "Comentarios")]
    public string Comments {
      get;
      set;
    }

    [Display(Name = "Departamento")]
    public int DepartmentId {
      get;
      set;
    }

    [Display(Name = "Categoría")]
    public int CategoryId {
      get;
      set;
    }
  }
}
    
asked by E.Rawrdríguez.Ophanim 08.12.2017 в 19:34
source

1 answer

1

Well, I'll try to answer some of those questions:

  • In the view you have item.Status but the property of the model is status with lowercase. The C # language is case-sensitive and that's why it's not being found.

  • With respect to the type of property status in your model, it is declared as string in the model, but it is int in the database. Either you declare it as int in both sites, or you create a enum .

  • The type varbinary in C # is byte[] . See this .

  • In general it is not necessary to put in the model all the data that appear in the table of the database. You can put only those that you will need.

answered by 08.12.2017 / 20:48
source