asp.net-coreentity-framework-coreaspnetboilerplate

ASP.NET Boilerplate EF Unable to determine the relationship


I started a new project by downloading the latest aspnetboilerplate solution from their site using MVC.

As soon as I add this code below to the WebDbContext I get the error also below. Even with no code inside that block I get the error.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}

DbContext' of type ''. The exception 'Unable to determine the relationship represented by navigation 'User.CreatorUser' of type 'User'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728


Solution

  • You could try add the base method:

            protected override void OnModelCreating(ModelBuilder modelBuilder)
            {
                base.OnModelCreating(modelBuilder);
            }