我有一个类库项目,其中包含我的DbContext和迁移,其配置文件如下:
<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.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<connectionStrings>
<add name="DataContext" connectionString="Data Source=Data.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
之前我曾尝试对该项目进行迁移操作,而 Get-Migrations 命令总是返回以下内容:
PM> Get-Migrations -StartupProjectName "Data"
Retrieving migrations that have been applied to the target database.
201207012104355_Initial
201207012031234_Initial
201207012024250_Initial
问题是即使我删除Data.sdf或删除所有项目并创建新项目,命令总是返回这些项。 我能创建新数据库的唯一方法是将连接字符串中的数据库文件名从Data.sdf更改为例如Data1.sdf。 那么如何在不更改数据库名称的情况下重置迁移历史记录?