Subsonic ActiveRecord and SQL Server Express

242 views Asked by At

I am trying out Subsonic ActiveRecord to determine if I want to use it on any upcoming projects, and I gotta say I really like it so far. It worked great with MS SQL Server 2005 and 2008, but I am having problems with the T4 Templates and SQL Server Express. From what I can tell, Subsonic is having a problem getting the schema info from the Server Express database that I added to a test MVC app.

Does anyone have info on getting it to work with Server Server Express (not Compact), and whether its even supported in Subsonic 3.0.0.4?

EDIT: This is an MVC app with MyTestDB in the App_Data folder. I have tried a number of various connection strings but nothing seems to work. The last string I have used is:

 <connectionStrings> 
    <add name="MyTestDBString" connectionString="server=.\SQLExpress;database=MyTestDB;integrated security=SSPI;User Instance=true" providerName="System.Data.SqlClient"/>
 </connectionstrings>

With the above string I am getting an SQL exception in the error list in Visual Studio saying Cannot Open Database... The login failed. This happens when I right click on the .tt files and run a custom tool.

1

There are 1 answers

1
AudioBubble On BEST ANSWER

You forgot to specify what database file to attach to a User SQL Server Instance. For example:

<connectionStrings>
     <add name="TestVB1.Settings.Database1ConnectionString" 
          connectionString="Data Source=.\SQLEXPRESS;
          AttachDbFilename=|DataDirectory|\Database1.mdf;
          Integrated Security=True;
          User Instance=True"
          providerName="System.Data.SqlClient" />
</connectionStrings>

See Opening a User-Instance Connection and Building your ASP.NET MVC application with Subsonic 3.0.

Hope it works out. Good luck!