0

using entity framwork code first approach, how can change default database directory to App_Data.

I tried with setting this path with custom db name in app.config but it always hits local sql server path in update-database.

2 Answers 2

2
  <?xml version="1.0" encoding="utf-8"?> 
<configuration> 
  <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" 
       type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
  </configSections> 
</configuration>

you could set the database initializer for a context using the appSettings section of the configuration file. In EF 4.3 we introduced the custom entityFramework section to handle the new settings. Entity Framework will still recognize database initializers set using the old format, but we recommend moving to the new format where possible.

The entityFramework section was automatically added to the configuration file of your project when you installed the EntityFramework NuGet package

See this Settings

Sign up to request clarification or add additional context in comments.

Comments

0

You may use the connection string for this.

<connectionStrings> <add name="here your context class name" connectionString="Data Source=.; Initial Catalog=databasename; user id=sa;password=*****; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> </connectionStrings>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.