Base solution for your next web application
Open Closed

Issue with default repository : getting null #2096


User avatar
0
prahlad created

Hi I really liked ASP.NET boiler plate framework, hats off to the framework. I am getting errors when I am using basic thing, please suggest me where I am going wrong. Thanks in advance.

After adding new entity to existing project, did made use of PM> Add-Migration "XXXX" and PM> Update-Database commands.

It successfully created table in the database whatever I specified in entity. I did add in DBContext also. But issue is when I want to use default repository for this, my Repository is null.

Here is my sample code, I made use of existing sample application added a new entity called JobLocation. When I am using while creating new JobLocation getting null in the repository.

Added in DBContext like below public class SimpleTaskSystemDbContext : AbpDbContext { public virtual IDbSet<Task> Tasks { get; set; }

    public virtual IDbSet&lt;Person&gt; People { get; set; }

    public virtual IDbSet&lt;JobLocation&gt; JobLocs { get; set; }

    public SimpleTaskSystemDbContext()
        : base("Default")
    {

    }

    public SimpleTaskSystemDbContext(string nameOrConnectionString)
        : base(nameOrConnectionString)
    {
        
    }

    //This constructor is used in tests
    public SimpleTaskSystemDbContext(DbConnection connection)
        : base(connection, true)
    {

    }

}

public virtual IDbSet<JobLocation> JobLocs { get; set; }


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Your definitions seems correct. Can you share the code with your repository where you get error ?

    Thanks.

  • User Avatar
    0
    prahlad created

    I fixed, not sure what happened I ran Update database again and then cleaned and rebuild it worked now I am able to get the default repository.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think your problem was related to something else. Maybe some seed data couldn't inserted to your database. This happens sometimes, and it crashes the application.