Home
Options

How does LINQPad handle MDF files?

edited April 2018
I am using 5.26.01. I was able to attach to an MDF file using the "Add connection" dialog, but after successfully running some queries, I suddenly started getting this error:

Cannot open user default database. Login failed.
Login failed for user

What I don't understand is how LINQPad is able to use this MDF file as a database, when I have not attached to it in SQL Server Management Studio. That is, my SQL Server Express installation does not know about this file, but LINQPad somehow gets SQL Server to access it. I am confused.

Closing and relaunching LINQPad did not resolve the above error. And now that I have deleted the connection, I am unable to add it back; there is a red X next to the connection.

Comments

  • Options
    Right-click the connection and choose Properties. What does it say under 'Server', 'Logon details' and 'Database'?
  • Options
    edited April 2018
    Hi Joe, thanks so much for responding. Just an update: I rebooted my machine, and then opened one of the queries with the problem connection. Surprise, as this time, the red cross was no longer present on the connection icon, and the query worked just fine!

    I am using an old Northwind.MDF file for doing some LINQ practices. My questions re: SQL Server was to gain an understanding of how LINQPad works seemlessly with the MDF file. When I look at my system through SQL Server Mgmt Studio, I don't see the Northwind database (which is as expected, because I did not import it in). But LINQPad is able to use it. How, that's what I was trying to understand.

    In any case, here's the properties sheet:

    2018-04-16_19_06_00-_LINQ_to_SQL_Connection
  • Options
    This is a feature of SQLExpress (and localdb). You can specify the name of a database to which to attach when creating a connection, without needing to register the database in advance.
Sign In or Register to comment.