C#C
C#2y ago
25 replies
Skenderbegu

Entity Framework 6 error - 'Value cannot be null. Parameter name: entitySet'

This piece of code is throwing the above error:

using (var dbContext = new ApplicationDbContext())
 {
                    var x = dbContext.WarningTypes.ToList(); <-- throws entitySet null 
                    ...
}


This is my WarningType class:

namespace Domain
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;

    public class WarningType
    {
        public Guid Id { get; set; }

        [Required]
        [StringLength(200)]
        public string Name { get; set; }

        [Required]
        public string Message { get; set; }
}


This is my DbSet in ApplicationDbContext.cs:

public virtual DbSet<WarningType> WarningTypes { get; set; }


I attached the database table picture for WarningTypes.
image.png
Was this page helpful?