The driver seems to be buggy / not updates at all. I found a way to bypass it by modifying the DbContext.
In theory, this should have worked, but it does not:
private string _connectionString;
public ApplicationDbContext(string connectionString) : base()
{
_connectionString = connectionString;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (_connectionString == null)
base.OnConfiguring(optionsBuilder); // Normal operation
// We have a connection string
var dbContextOptionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(_connectionString);
base.OnConfiguring(dbContextOptionsBuilder);
}
LinqPad EF Core driver keeps looking for the parameterless constructor even if you specify "Via a constructor that accepts a string". That seems like a bug in the driver.
So then I gave it what it wanted, a parameterless contructor. I had to hardcode the connection string since IoC/appsettings.json config reader is not loaded and I don't feel like loading that separately in the DbContext. But it works and lets me test EF Core queries in LinqPad off my model.
This works fine for me:
private bool _isDebug = false;
public ApplicationDbContext() : base()
{
_isDebug = true;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!_isDebug)
base.OnConfiguring(optionsBuilder); // Normal operation
// We are in debug mode
var dbContextOptionsBuilder = new DbContextOptionsBuilder();
// Hardcoded connection string
optionsBuilder.UseSqlServer("data source=XXXX;initial catalog=XXXX;persist security info=True;user id=XXXX;password=XXXX;MultipleActiveResultSets=True;App=EntityFramework");
base.OnConfiguring(dbContextOptionsBuilder);
}
This is in addition to the existing public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
of course.
Edit: Be careful, it looks like this overrides default behavior, which may not be visible until you deploy to the server.