Value cannot be null. Parameter name: entitySet

user1752532 picture user1752532 · Mar 27, 2014 · Viewed 35.5k times · Source

I have a fairly standard setup with simply POCO classes

public class Project
{

    public int ProjectId { get; set; }
    public string Name { get; set; }
    public int? ClientId { get; set; }
    public virtual Client Clients { get; set; }
}

They use an interface

public interface IProjectRepository
{
    IEnumerable<Project> Projects { get; }
}

and are constructed as a repository for ninject to bind to

public class EFProjectRepository : IProjectRepository
{
    private EFDbContext context = new EFDbContext();

    public IEnumerable<Project> Projects
    {
        get { return context.Projects; }
    }
}

The actual context is a simply DbContext

public class EFDbContext : DbContext
{
    public DbSet<Project> Projects { get; set; }
}

When I try and enable code first migrations I get the following error

image of error

I have done this exact process with other projects and there as never been an error. This is connecting to a local Sql Server Database. There does not seem to be a problem with the connection string. I have searched for this error online but the solutions seem to answer questions that do not directly relate to my setup.

Answer

Th4t Guy picture Th4t Guy · Aug 26, 2015

I had the same issue and the cause was a POCO class that had a property of type Type.