locked
Entity Framework - Change database name RRS feed

  • Question

  • User521171331 posted

    Hi, I tried the tutorial here - https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/

    After I change my database name, example "mydatabase.mdf" and in my web.config, I also set "mydatabase" as my connection name value and also in my dbcontext, I also change my code to:

        public ProductContext()
          : base("mydatatabase")
        {
        }

    My application works, but when I view my server explorer (I use localdb), there are 'two' mydatabase and auto-generated tables were created inside mydatabase (WingtipToys), instead of mydatabase. Why? or How do I remove the text "WingtipToys"?

    Wednesday, April 5, 2017 2:54 PM

Answers

  • User1771544211 posted

    Hi ngaisteve,

    Could you please share your web.config file here?

    You can check the property of the Database by right click on the Database, click Property.  Then a window shows the property of the Database will show, you can check the connection string of the database and other properties.

    Best Regards,

    Jean

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 6, 2017 6:39 AM

All replies

  • User1771544211 posted

    Hi ngaisteve,

    Could you please share your web.config file here?

    You can check the property of the Database by right click on the Database, click Property.  Then a window shows the property of the Database will show, you can check the connection string of the database and other properties.

    Best Regards,

    Jean

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 6, 2017 6:39 AM
  • User521171331 posted

    Hi here you go:

    <connectionStrings>    
        <add name="mydatatabase" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\wingtiptoys2.mdf;Integrated Security=True"
          providerName="System.Data.SqlClient" />
      </connectionStrings>

    Just wondering why in my web.config, i have wingtiptoys2.mdf but in my App_Date, my database name is mydatabase.mdf?

    Thursday, April 6, 2017 9:38 AM
  • User521171331 posted

    Its okay. Somehow, I manage to solve already. Thanks.Cool

    Thursday, April 6, 2017 9:43 AM