0

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

Guy
  • 336
  • 4
  • 18
  • So you are creating just UI for what powershell already gives you? What is wrong with using powershell? – Ladislav Mrnka Jul 09 '12 at 08:06
  • we have a complex application with quite a few programmers. I created a wrap for DB using EF code first. the utility i created creates all the backing code for EF. so since i gave the ability to edit pocos, i would also like to do the migrations automatically. I dont want programmers to edit the pocos and then go to the powershell. somewhere along the way someone will mess things up. – Guy Jul 09 '12 at 08:34
  • You mentioned you have programmers - aren't programmer supposed to write a code instead of using some GUI to "click" the code? Looks like you are putting great effort to make programmers live harder. Also there are already tools for POCO generation: EDMX + T4 templates. – Ladislav Mrnka Jul 09 '12 at 08:38

1 Answers1

2

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.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670