Note that there are some explanatory texts on larger screens.

plurals
  1. POScripting EF Add-Migration into an automated build task
    primarykey
    data
    text
    <p>I have all my ef code first migrations in a separate assembly called <code>Migrations</code></p> <p>From the package manager console I type <code>Add-Migration xyz</code> which scaffolds up a migration</p> <p>Is it possible to do this from outside of visual studio? I'm using rake scripts to do lots of automation for my build but this is one part that I've not quite got yet. The goal here would be to do the following</p> <p><code>rake db:add_migration "xyz"</code></p> <p>This would run some command and add the migration to the specified project. That's the only bit I've not been able to figure out how to automate yet! I'd probably build in other tasks along with this like dropping and creating the database and the getting the migration out to a script so it could be run under my roundhouse migrations.</p> <p>Related material</p> <pre><code>Add-Migration [-Name] &lt;String&gt; [-Force] [-ProjectName &lt;String&gt;] [-StartUpProjectName &lt;String&gt;] [-ConfigurationTypeName &lt;String&gt;] [-ConnectionStringName &lt;String&gt;] [-IgnoreChanges] [&lt;CommonParameters&gt;] </code></pre> <p><a href="http://coding.abel.nu/2012/03/ef-migrations-command-reference/#Add-Migration" rel="noreferrer">Command Reference</a></p> <p>I can see that EF is installed to the packages folder from nuget</p> <pre><code>packages\EntityFramework.5.0.0\tools </code></pre> <p>And I can see in the file <code>EntityFramework.psm1</code></p> <pre><code>function Add-Migration { [CmdletBinding(DefaultParameterSetName = 'ConnectionStringName')] param ( [parameter(Position = 0, .... } </code></pre> <p>But I'm not sure how to execute it from the command line. I've tried </p> <pre><code>..\packages\EntityFramework.5.0.0\tools&gt;powershell EntityFramework.psm1 Add-Migration </code></pre> <p>but this results in an error</p> <pre><code>The term 'EntityFramework.psm1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:21 + EntityFramework.psm1 &lt;&lt;&lt;&lt; Add-Migration + CategoryInfo : ObjectNotFound: (EntityFramework.psm1:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload