Forget SQL, All My Homies Use LINQ

Learning SQL is a pain. Using SQL is a pain. Be better. Choose .NET. Choose LINQPad.

Early last year I was building out a database site for a game and decided it would be a good opportunity to start playing with Entity Framework (or EF Core, as it's now called) that I'd been meaning to get into for awhile, but never got to using. I already had my database setup and some data inserted but I figured it wasn't a big deal to just re-write it with EF Core and generate a new database.

But after some digging, I discovered that EF Core actually has functionality specifically for the case of reverse engineering an existing SQL schema and generating the associated .NET models: scaffolding

Scaffolding, Yay

dotnet ef dbcontext scaffold "server=;uid=root;pwd=password;database=classicmodels" Pomelo.EntityFrameworkCore.MySql

You just provide the database connection string and the SQL provider package (SqlServer, MySql, etc.), and EF Core will handle the rest. Note that you'll also need the global dotnet-ef package for this to work, which you can install with the following:

dotnet tool install --global dotnet-ef

This was brilliant, so I generated some models and I was immediately able to run LINQ queries on my database, no effort required.

But then I realized, this would be extraordinarily useful as a dedicated app: to be able to connect to a database and start manipulating it directly within your app with LINQ, rather than having to use the syntactically unappealing and generally displeasing SQL. Okay, it's not that bad, but I've always disliked the structure and semantics.

So I got to work and started building a prototype. When Monday came, and I informed one of my colleagues about my clever idea and the project I started building out, to which he replied "isn't that just LINQPad?"


LINQ is probably one of the most beloved aspects of .NET.

And LINQPad takes advantage of that. You can connect to a variety of SQL database flavors and it will generate the models and display a code editor within the app, and it supports all of the .NET languages (VB, C#, F#, etc), has a useful model explorer, and even has intellisense and integrated debugging. When you run your LINQ queries you can then output it in a grid format, exactly like you'd see in something like MySQL Workbench. It really was everything I wanted, and more. The only qualm I have is that it is Windows only...

LINQPad, where have you been my whole life?