Value cannot be null. Parameter name: entitySet

前端 未结 12 1838
夕颜
夕颜 2020-12-03 17:02

I have a fairly standard setup with simply POCO classes

public class Project
{

    public int ProjectId { get; set; }
    public string Name { get; set; }
          


        
12条回答
  •  伪装坚强ぢ
    2020-12-03 17:41

    For anyone not finding a resolution in the other answers, I got this error when I created a derived class from a class that had an instance in some model. The exception occurred on the first usage of my context in a request.

    This is a stripped-down example that will reproduce the behaviour. Model is a DbSet in my context.

    public class Model
    {
        public int Id { get; set; }
        public Duration ExposureDuration { get; set; }
    }
    
    public class Duration
    {
        public int Value { get; set; }
        public string Unit { get; set; }
    }
    
    //Adding this will cause the exception to occur.
    public class DurationExtended : Duration
    { }
    

    This happened during work in progress. When I changed the model property ExposureDuration to type DurationExtended, all was working again.

提交回复
热议问题