You can use a SQL Server 2005 (or 2008) database with a Web Application or Web Site project. You can probably have the database files (.mdf
, .ldf
) in the App_Data
folder (and remember you need to attach the database1 to SQL Server directly—the auto-connect file only works with Express).
But you do need to ensure the data connections used by the application are set to use connection strings defined in the application's own web.config
. By default things like the membership provider default to a SQL Express database in App_Data
due to the contents of the global machine.config
2 setting the membership provider to use connection
LocalSqlServer
which is set in the same file to be:
data source=.\SQLEXPRESS;Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Where |DataDirectory|
will be replaced at runtime by App_Data
in the application root.
Summary the application, (web.config, VS's data connections are not used outside the designer) needs to either:
- Use SQL Express.
.mdf
in the App_Data folder with a connection string using "AttachDBFilename
".
- Use SQL Server (full) with the database configured (persistently) in SQL Server with the data files (
.mdf
, .ldf
) in a location that the SQL Server user account can access. All the connection strings reference that database via "Data Source
" (to set server name) and "Initial Catalog
" to set the database. The account for the IIS application pool needs to be able to access SQL Server.
1 Use SQL Management Studio to do this. (And thanks to the other answer for reminding me.)
2 See %SystemRoot%\\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
. The