Home
Options

LINQPad 7 - Connection Issues

I have development and production databases for several applications. Despite creating two connections in LINQPad,
and using the 'via constructor that accepts DbContextOptions' to specify my connection string, my 'production' connection will apparently connect to my development database.

This occurs when developing queries using 'C# Statements' and selecting the production connection in the 'Connection' drop-down.
Yesterday, the window started off connecting to production (which has newer data) - then at some point, I lost the newer data.
I spent about an hour re-writing my query, thinking a join had 'lost' the newer data, when I finally realized that I was connected to the development database, rather than production.
I determined this by copying the generated SQL into the MS SSMS tool, and running it against dev and prod databases.

Currently using LINQPad 7.8.7 (X64) Free Edition with .Net 6 EF Core DLLs from our application.

Here is the odd thing. The data is definitely coming from the development database, and I typically write my test code like this, in order to be able to 'copy paste' code from LINQPad into my application.

var _context = this;
var query = _context.SomeTable.Where( x => x.Column = "test");
query.Dump();
// for testing:
var conn = _context.Database.GetDbConnection();
conn.ConnectionString.Dump();

I just added the bottom two lines, in hopes it would confirm that it is connecting to the dev database, but it actually did return the string I have set in the DbContext Connection 'Via c constructor that accepts a DbContextOptions<>'... so now I'm even more puzzled.
But I am positive that I am connection to the dev db from the prod connection, as I've changed a couple of record values to confirm.

Not sure if this is a bug in LINQPad, or a result of an issue related to how we are creating our Data.DLLs (happens with more than one application instance)

Comments

Sign In or Register to comment.