一段时间以来,我们一直在使用Entity Framework代码优先迁移技术。一切正常,但是由于我们对实体架构进行的更改,我们的Migrations文件夹变得越来越大,包含大量迁移文件。我很好奇,有没有一种方法可以在实体发生变化时仅更新一个或特定数量的文件,以使我们的Migrations文件夹看起来不那么混乱。另外,我不想删除表并重新创建它,因为我将丢失所有已保存的数据。
We are using Entity Framework code first migration technique for a while now. Everything works good however our Migrations folder has been growing big with numerous migration files because of changes we are making on entity schema. I was curious, is there a way we can update just one or specific number of files whenever there is change in entity so that our Migrations folder would look less messy. Also, i don't want to drop the table and recreate it since i will be loosing all the saved data.
推荐答案您可以简单地将所有迁移合并到一个新文件中(如果您不关心保留每个迁移)。
You could simply merge all of your migrations into a new file (if you aren't concerned with keeping every migration).
要这样做,只需删除文件夹中当前的每个迁移,然后重新运行enable-migrations命令,然后再运行add-migration命令即可。
To do so, simply delete every migration currently in the folder, and rerun the enable-migrations command and then the add-migration command like so.
Enable-Migrations add-migration InitialCreate更多推荐
实体框架代码优先迁移
发布评论