我已经启用了迁移:
enable-Migrations -ProjectName ProjectOne -ContextTypeName MyIdentity.Config.MyIdentityContext -MigrationsDirectory Identity\\Migrations
Run Code Online (Sandbox Code Playgroud)
我指定了我的上下文,因为它位于一个单独的命名空间中,我指定了该目录,因为我希望将迁移放在不同的目录中.
启用此类迁移后,我在预期位置(Identity\Migrations文件夹)中获取预期的配置文件(我删除了种子过程中的注释)
Friend NotInheritable Class Configuration
Inherits DbMigrationsConfiguration(Of MyIdentityDbContext)
Public Sub New()
AutomaticMigrationsEnabled = False
MigrationsDirectory = "Identity\\Migrations"
End Sub
Protected Overrides Sub Seed(context As MyIdentityDbContext)
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
在此之后我创建了一个迁移:
add-migration Initial
Run Code Online (Sandbox Code Playgroud)
但后来我得到一个错误,说明该文件已经存在:
Scaffolding migration 'Initial'.
System.Runtime.InteropServices.COMException (0x80040400): Unable to add '201506111233565_Initial.vb'. A file with that name already exists.
Server stack trace:
at EnvDTE.ProjectItems.AddFromFileCopy(String FilePath)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: …Run Code Online (Sandbox Code Playgroud) .net entity-framework code-first ef-code-first ef-migrations