Value cannot be null. Parameter name: entitySet

entity-framework, entity-framework-migrations

Solution

This problem can occur if one of the POCO classes was not declared in the DbContext.

I added them and the error went away

I had changed the name of the `Task` POCO class because of its association with a built in .NET name `System.Threading.Tasks`. However I had not changed this in the "TaskTimeLog" POCO where there was a relation. When going through the code the "Task" property in the "TaskTimeLog" POCO was not showing an error because it was now attached to that threading keyword and the reason I had changed the name in the first place.

Problem

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 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.

Original source