It appears that the driver is malfunctioning / not updating. I found a way around it by modifying the DbContext.
In theory, this should work, but it is not:
private string _connectionString; public ApplicationDbContext(string connectionString) : base() { _connectionString = connectionString; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (_connectionString == null) base.OnConfiguring(optionsBuilder);
The LinqPad EF Core driver continues to search for a constructor without parameters, even if you specify "Through the constructor that takes a string." This is similar to a driver error.
So, I gave him what he wanted, an inconspicuous constructor. I had to hardcode the connection string, as the IoC / appsettings.json config reader is not loaded, and I don't feel like loading it separately in DbContext. But it works and allows me to test the EF Core queries in LinqPad from 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);
This is, besides the existing public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
, of course.
Edit: Be careful, this seems to override the default behavior, which may not be displayed until you deploy to the server.
source share