我正在创建一个示例性的简单应用程序,它使用 Code First EF 和迁移。我有一个上下文对象,如果尚不存在使用 defaultConnectionFactory 的数据库,它会为自己创建一个数据库。我想知道如何覆盖这些设置,以控制数据库名称。即使我注释掉 defaultConnectionFactory 并放置连接字符串,我仍然得到相同的旧数据库名称。为什么?
<?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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <!--<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>-->
  <connectionStrings>
    <add name="MigrationsDemoConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MigrationsDemo;Integrated Security=true" providerName="System.Data.SqlClient" />
  </connectionStrings>  
</configuration>