Run entityframework cmdlets from my code

强颜欢笑 提交于 2019-12-24 23:35:31

问题


I am creating a small program over entityframework which allows to edit the POCOs with a UI. as part of the process i would like to call the "add-migration" command from my code to save the interaction of the rest of the programmers with the program manager console. is it possible at all?

thanks


回答1:


Add-Migration cmdlet is defined in separate EF 4.3 Powershell assembly used by Package manager console. This assembly references a real EF 4.3 assembly. The core logic exposed from that assembly is ToolingFacade class from System.Data.Entity.Migrations.Design namespace. The exposed logic involves retrieving database and pending migrations and scaffolding a new migration but PowerShell assembly contains the execution workflow and creates bridge between EF, PowerShell and Visual studio (adding classes to your project) - this is what you must reverse engineer and reimplement in your tools.

Edit: You can also try to run MigrationCommands.AddMigration directly from PowerShell assembly.



来源:https://stackoverflow.com/questions/11391143/run-entityframework-cmdlets-from-my-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!