Cannot get nutshell mdf to work

I have followed the directions from readme below
// If you don't have SQLExpress installed, the connection on the left will display in red
// and this query will throw an exception. This might be the case if you have installed
// the full-blown SQL Server instead of SQLExpress. The solution is to create your own
// database as follows:
// 1. Right-click "Nutshell.mdf" on the left, and choose "Edit".

rem There is no "Edit" to choose! Did you mean "Properties" ?

// 2. Select an empty database (or create a new one) on a server of your choice.
// 3. Click "Remember this connection" and OK
// 4. Execute the "Populate Demo Database" script in the next example.

What can I do since there is no "Edit" to click on?
I am running Windows 7 professional and have Visual Studio 2013 professional installed and working as it should, as far as I know. I can send screen copies, if you wish.


  • Yeah, speaking as total noobie in SQL and LINQ, the authors blunder (I wonder if they don't have time or just don't care?) by assuming that "create an empty database" means something to everybody reading C# Nutshell... Ok, took me two days to figure this out, following along in the Linqpad 5 minutes.. tutorial. First, you need to determine what database engine(s) you have access to. In my case, I didn't know what I was doing, so may also have blundered. I downloaded the free version of SQL 2014 Express (in late May, is now talking about SQL 2016, but its not available afaik yet.) (Oh, I also downloaded Adventure Works 2014 and 2014 DW (data warehouse), both 64 bit). I also downloaded the SQL Management Studio, but to be clear: I am NOT at all sure that either the full SQL Express or the Mgmt Studio are necessary. There were some other db engines on my machine (some named "local..." something or other, and also there is a folder called SQL Compact Edition (which may or may not be the same thing, idk)). So, I'd try to connect to these before downloading the full SQL Express. Anyway, it is up to you to find the location of the database engine you have access to. Mine are in the C:Program Files folder (sub-folders of) but I understand that 32 bit may be under Program Files(x86), and I'm vaguely thinking that I saw something under my Visual Studio folder (maybe the "local..." engines??). You Explore. (Oh, I know the OP has probably retired or gone into managment, and no longer cares, but this is for posterity...) So, to sum up what I believe: A db is run by a db-engine. My databases, including master and NORTHWND_stub (which I created) is located in the DATA subfolder of the database engine folder. In my case its C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA but ymmv. I suggest you check out the locations (including parent directories) of any folders which have *.mdf files (especially in data folders). Anyway...
    To create a db is simple. Following along in the Linqpad 5 min... tutorial, I got to the query "What about.." and didn't have Northwind (NORTHWND) db. So, I moved on to the next one which essentially told me to "create" it. LOL. Talk about self-referential. If I knew how to create it, would I need the tutorial? Oh, well... OK, here is what I did (and I hope it is correct, I'm a bit uneasy in my use of the master db, in my profound ignorance, but it worked, so...)OK. You've located a db engine and know its path. So you can click on the "Add connection" in the left-hand window and connect to it. It should populate a tree of db's, one of which must be (I think) master. So, in a new query (from the file menu) choose SQL as the language (above the query window) and master as the connection. Then type "create database " without the quotes, and where you pick a unique name for your db. Since the "but I don't have..." tutorial claims you'll be recreating part of the northwind db, I named mine NORTHWND_stub. Specifically the command I used was: CREATE DATABASE NORTHWND_stub //then hit F5
    OK? You're done. You can go on to execute the tutorial query "But I don't have..." and then the previous one. Right? Wrong. Frustrating BUG in Linqpad! After you do that you have to close down Linqpad. Then reopen it. Under the connections, you should now see NORTHWND_stub (or whatever name you chose). And you can go on to use it as the connection (above the query) and execute the "But I..." and then the "What about..." queries. BTW, there's no need to save the query which created the db. Hope this helps.
  • Thank you daven for a fun read and a right answer. I too was baffled by the non-existent "Edit", but I solved the problem by following your instructions.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!