Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
703 views
in Technique[技术] by (71.8m points)

entity framework - Value cannot be null. Parameter name: entitySet

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...