locked
MDF db connectionString during deployment RRS feed

  • Question

  • User295532487 posted

    I have a MVC application using .mdf database and the connection string for it is 

    connectionString="Data Source=(localdb)\v11.0;initial catalog=MVCApplication;Integrated security=SSPI; AttachDBFilename=|DataDirectory|\DB1.mdf;User instance=false"

    The .mdf database file is in the APP_Data folder

    If I want to deploy this application to the server, how should I modify the connection string? And what actually is the user instance mean?

    Tuesday, December 25, 2012 10:36 PM

Answers

  • User197322208 posted

    I want to deploy this application to the server, how should I modify the connection string?

    to the connection string of the database - or you can even let this, if you want to use database from App_Data

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2012 11:46 PM
  • User-151368862 posted

    You need to modify the bold part to point to your deployment machine SQL server name:
    Data Source=(localdb)\v11.0;

    And also it is likely that you must care for Integrated Security and User instance setting as well

    Here is a good explanation for instances:
    http://msdn.microsoft.com/en-us/library/bb264564%28v=sql.90%29.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2012 11:47 PM

All replies

  • User197322208 posted

    I want to deploy this application to the server, how should I modify the connection string?

    to the connection string of the database - or you can even let this, if you want to use database from App_Data

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2012 11:46 PM
  • User-151368862 posted

    You need to modify the bold part to point to your deployment machine SQL server name:
    Data Source=(localdb)\v11.0;

    And also it is likely that you must care for Integrated Security and User instance setting as well

    Here is a good explanation for instances:
    http://msdn.microsoft.com/en-us/library/bb264564%28v=sql.90%29.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 25, 2012 11:47 PM
  • User295532487 posted

    Basically, my database is located under App_Data folder. Won't the data source=(localdb)\v11.0 will throw an error if i deploy on a server?

    Btw, .sdf and .mdf, which database is better to use in a very large scale application?

    Wednesday, December 26, 2012 4:12 AM
  • User-743147585 posted

    As an example, please use following

    <add name="MusicStoreEntities" connectionString="Data Source=(local);Initial Catalog=MvcMusicStore;Integrated Security=True" providerName="System.Data.SqlClient" />

    Wednesday, December 26, 2012 4:48 AM
  • User295532487 posted

    throw some error when I use your connection string. 

    Is it ok to not to specify the database file name?

    Wednesday, December 26, 2012 10:01 PM
  • User197322208 posted

    throw some error when I use your connection string. 

    What error? And what you want to be your database at deployment?

    Wednesday, December 26, 2012 11:32 PM
  • User295532487 posted

    It throws an error "Cannot access database by current user".

    I think I need to grant the permission to some specific user (xxx) first before I change the connection string to 

    <add name="MusicStoreEntities" connectionString="Data Source=(local);Initial Catalog=MvcMusicStore;Integrated Security=True; uid=xxx; password=xxx" providerName="System.Data.SqlClient" />


    Thursday, December 27, 2012 3:49 AM
  • User-1291379147 posted

    as far as I understand, you must use aspnet_regsql to move your sql server. after that you can do what you said.

    click here for more details

    Thursday, December 27, 2012 4:11 AM
  • User197322208 posted

    Integrated Security=True; uid=xxx; password=xxx

    put integrated to false to use uid + pwd.

    Thursday, December 27, 2012 4:27 AM
  • User295532487 posted

    it works..~ but the database is not located under App_Data folder anymore.

    Thursday, December 27, 2012 10:02 PM
  • User197322208 posted

    it works..~ but the database is not located under App_Data folder anymore.

    of course. It is not the same connection string like in prod, right?!

    Thursday, December 27, 2012 11:41 PM