Sorry I do not understand why you do not let me list my model, I have this image with the error
public IEnumerable GetBalances () { var list = new List ();
using (var db = new ApplicationDbContext())
{
var query = db.Balanza;
listado = query.ToList();
}
return listado;
}
My model is this
public class Balanza
{
[Key]
public int BalanzaID { get; set; }
[Display(Name = "Codigo de Balanza:")]
[Required(ErrorMessage = "Debe ingresar el codigo de la Balanza")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Cod_Balanza { get; set; }
[Display(Name = "Marca:")]
[Required(ErrorMessage = "Debe ingresar la marca")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Marca { get; set; }
[Display(Name = "Serie:")]
[Required(ErrorMessage = "Debe ingresar la serie")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Serie { get; set; }
[Display(Name = "Fabrica:")]
[Required(ErrorMessage = "Debe ingresar la fabrica")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Fabrica { get; set; }
[Display(Name = "Modelo:")]
[Required(ErrorMessage = "Debe ingresar la modelo")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Modelo { get; set; }
[Display(Name = "Descripcion de Balanza:")]
[MaxLength(150, ErrorMessage = "El campo no debe exceder 150
caracteres")]
public string Des_balanza { get; set; }
[Display(Name = "Tipo de Balanza(1:manual,2:automática):")]
[Required(ErrorMessage = "Debe escoger el tipo de balanza")]
public char Tip_balanza { get; set; } //1:manual, 2:automatica
[Display(Name = "Tipo de Situación de
balanza(1:propio,2:alquilado,3:ajeno):")]
[Required(ErrorMessage = "Debe escoger el situación de la balanza")]
public char Sit_balanza { get; set; }//1:propio,2:alquilado,3:ajeno
[Display(Name = "Propietario de la balanza:")]
[Required(ErrorMessage = "Debe ingresar el propietario de la balanza")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string Pro_balanza { get; set; }
[Display(Name = "Capacidad máxima:")]
[Required(ErrorMessage = "Debe ingresar la capacidad máxima")]
[Range(0, 9999999, ErrorMessage = "Íncorrecto, no puede ser menor que
0.")]
public decimal Cap_maxima { get; set; }
[Display(Name = "Capacidad mínima:")]
[Required(ErrorMessage = "Debe ingresar la capacidad mínima")]
[Range(0, 9999999, ErrorMessage = "Íncorrecto, no puede ser menor que
0.")]
public decimal Cap_minima { get; set; }
[Display(Name = "Ubicación:")]
[Required(ErrorMessage = "Debe ingresar la ubicación")]
[MaxLength(20, ErrorMessage = "El campo no debe exceder 20 caracteres")]
public string ubicacion { get; set; }
[Display(Name = "Fecha de Fabricación:")]
[Required(ErrorMessage = "Debe ingresar la Fecha de Fabricación")]
public DateTime Fec_fabricacion { get; set; }
[Display(Name = "Fecha de Ingreso:")]
[Required(ErrorMessage = "Debe ingresar la Fecha de ingreso")]
public DateTime Fec_ingreso { get; set; }
[Display(Name = "Estado(1:activo,2:inactivo):")]
[Required(ErrorMessage = "Debe ingresar la Fecha de ingreso")]
public char Estado { get; set; } // 1:activo,2:inactivo
//datos de auditoria
public string usuario { get; set; }
public DateTime? Fec_modificacion { get; set; }
public DateTime? Fec_stamp { get; set; }
public string programa { get; set; }
}
the modelBuilder is this:
modelBuilder.Entity("REQ.UI.WEB.Models.Entities.Balanza", b =>
{
b.Property<int>("BalanzaID")
.ValueGeneratedOnAdd();
b.Property<decimal>("Cap_maxima");
b.Property<decimal>("Cap_minima");
b.Property<string>("Cod_Balanza")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<string>("Des_balanza")
.HasAnnotation("MaxLength", 150);
b.Property<char>("Estado");
b.Property<string>("Fabrica")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<DateTime>("Fec_fabricacion");
b.Property<DateTime>("Fec_ingreso");
b.Property<DateTime?>("Fec_modificacion");
b.Property<DateTime?>("Fec_stamp");
b.Property<string>("Marca")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<string>("Modelo")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<string>("Pro_balanza")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<string>("Serie")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<char>("Sit_balanza");
b.Property<char>("Tip_balanza");
b.Property<string>("programa");
b.Property<string>("ubicacion")
.IsRequired()
.HasAnnotation("MaxLength", 20);
b.Property<string>("usuario");
b.HasKey("BalanzaID");
b.ToTable("Balanza");
});
In another project that I have if it works normally, but when I create this project I get that error when I show it in View as List
public IActionResult ListarBalanzas()
{
var model = balanzaAD.GetBalanzas();
return View(model);
}
I will be attentive if any other information is needed to solve this problem. I already tried to drop the database and again do the Update-Database to see if that was a problem but it does not solve it.