I am getting this error when I try to launch my website using WebMatrix. I have a .cs file which makes a call var db = Database.Open("dbase");.
I have a database in my project called “dbase”. I have no web.config file and no imports for using WebMatrix packages since I am launching the site using WebMatrix, so I don’t believe I should need them. Do I need to wrap the code in Razor tags, like @{var db = Database.Open("dbase"); } ? This causes an error for me too.
What could be causing this? Does anyone have any solutions for this?
You need a reference to the
WebMatrix.Data.dllassembly (which you probably have) and you also need ausingdirective for theWebMatrix.Datanamespace:That will import the
Databaseclass so you can use it without fully-qualifying the name.It’s not clear why you think you wouldn’t need any “imports” (by which I assume you mean using directives like the one above) but if this is in a plain C# file, then you certainly do need them (or you need to fully-qualify type names, which is ugly).