Error in fetch(key): lazy-load database in base R
This is an Rstudio problem with the current session, but there is an easy fix for it.
Simply restart your Rstudio!
Solution found here.
Failing to load the new ggplot2 in R
You should restart R after re-installing ggplot2. See the following Stackoverflow link as this is a similar problem
Error in fetch(key) : lazy-load database
Getting attempt was made to lazy-load navigation property on detached entity despite eager fetch
For posterity, here's the response from the EF Core team:
This is because lazy-loading isn't supported for NoTracking queries
(#10042) but we tried to not make it throw if it looked like
lazy-loading wasn't needed. In retrospect it might have been better to
always throw. Note that the warning can be configured to not throw
using ConfigureWarnings in the DbContextOptionsBuilder.
Just in case it's of use for someone, what I ended up doing was creating a second "ReadOnlyRepository" configured to not use lazy loading and to always return untracked sets. I use this repository for queries where I'm never going to persist changes to any of the entities, where the resultset can be large and when it needs to perform well.
public class ReadOnlyRepository : MainDbContextBase, IReadOnlyRepository
{
public ReadOnlyRepository(IConfigurationSettings configurationSettings)
: base(configurationSettings, false)
{
}
public IQueryable<T> Retrieve<T>() where T : class, IAmAnAggregateRoot
{
return GetDbSet<T>().AsNoTracking();
}
}
public class MainDbContextBase : DbContext
{
private readonly IConfigurationSettings configurationSettings;
private readonly bool useLazyLoading;
protected MainDbContextBase(IConfigurationSettings configurationSettings, bool useLazyLoading)
{
this.configurationSettings = configurationSettings;
this.useLazyLoading = useLazyLoading;
}
protected DbSet<T> GetDbSet<T>() where T : class
{
return Set<T>();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder
.UseLazyLoadingProxies(useLazyLoading)
.UseSqlServer(configurationSettings.ConnectionString);
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
...
}
}
}
Related Topics
Combining Pivoted Rows in R by Common Value
Regex Match Exact Number of a Specific Character
How to Find Index of Match Between Two Set of Data Frame
How to Read in Multiple ".Xlsx" Files to R
The Right Way to Plot Multiple Y Values as Separate Lines with Ggplot2
Dplyr::N() Returns "Error: This Function Should Not Be Called Directly"
Replacing All Occurrences of a Pattern in a String
Scale/Normalize Columns by Group
R Shiny Observe Running Before Loading of UI and This Causes Null Parameters
Auto Complete and Selection of Multiple Values in Text Box Shiny
Reshape Wide to Long with Character Suffixes Instead of Numeric Suffixes
R Shiny Conditionalpanel Output Value
Devtools::Install_Github Fails with Ca Cert Error
Shrink Dt::Datatableoutput Size
Hollow Histogram or Binning for Geom_Step
Creating R Package, Warning: Package '---' Was Built Under R Version 3.1.2