Search code examples
sql-servermdfapp-datadatadirectory

how to use an mdf in App_Data with shared hosting


If I create a website that uses an mdf in App_Data with the connection string:

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

what do I need to do to run the site in a shared hosting environment? Do I need to copy the contents of my mdf to the main SQL Server engine of my host? Is there a way to use the non-SQLExpress engine of my host and still keep my mdf in my App_Data?


Solution

  • Mdf files will only work with SQL Server engines (Express or the full versions). The provider you use will need to provide access to a SQL Server engine. As Gortok said, a lot depends on the provider. See their documentation for the details.