EF Code First Migrations Update-Database Parameters Documentation?

In my recent Code First Migrations course on Pluralsight.com, I showed how you can get detailed information about the parameters of update-database. These can also be used if you want to execute the migrations from the command line using the counterpart migrate.exe command rather than from within Visual Studio.

You can get at the details from the Package Manager Console in Visual Studio with the get-help commandlet as shown below. Or if you are using the command line just type migrate –? as you can see in this blog post I wrote about executing migrations from the command line. I don’t know how to get the “full” information from the command line but it’s available in the Package Mgr Console and displayed below.

  • -detailed gives a description of each parameter.
  •  –full provides the description and then even more detail about how to use each parameter. I show that output below the output of the DETAILED display.

(Note, I just had to correct the misspelling of omitted when I pasted this in. Smile )

PM> get-help update-database -detailed

NAME
    Update-Database
   
SYNOPSIS
    Applies any pending migrations to the database.
   
   
SYNTAX
    Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUp
    ProjectName <String>] [-ConfigurationTypeName <String>] [-ConnectionStringName <String>] [<CommonParameters>]
   
    Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUp
    ProjectName <String>] [-ConfigurationTypeName <String>] -ConnectionString <String> -ConnectionProviderName <String> [<Common
    Parameters>]
   
   
DESCRIPTION
    Updates the database to the current model by applying pending migrations.
   

PARAMETERS
    -SourceMigration <String>
        Only valid with -Script. Specifies the name of a particular migration to use
        as the update’s starting point. If omitted, the last applied migration in
        the database will be used.
       
    -TargetMigration <String>
        Specifies the name of a particular migration to update the database to. If
        omitted, the current model will be used.
       
    -Script [<SwitchParameter>]
        Generate a SQL script rather than executing the pending changes directly.
       
    -Force [<SwitchParameter>]
        Specifies that data loss is acceptable during automatic migration of the
        database.
       
    -ProjectName <String>
        Specifies the project that contains the migration configuration type to be
        used. If omitted, the default project selected in package manager console
        is used.
       
    -StartUpProjectName <String>
        Specifies the configuration file to use for named connection strings. If
        omitted, the specified project’s configuration file is used.
       
    -ConfigurationTypeName <String>
        Specifies the migrations configuration to use. If omitted, migrations will
        attempt to locate a single migrations configuration type in the target
        project.
       
    -ConnectionStringName <String>
        Specifies the name of a connection string to use from the application’s
        configuration file.
       
    -ConnectionString <String>
        Specifies the the connection string to use. If omitted, the context’s
        default connection will be used.
       
    -ConnectionProviderName <String>
        Specifies the provider invariant name of the connection string.
       
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".
   


PM> get-help update-database -full

NAME
    Update-Database
   
SYNOPSIS
    Applies any pending migrations to the database.
   
SYNTAX
    Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUp
    ProjectName <String>] [-ConfigurationTypeName <String>] [-ConnectionStringName <String>] [<CommonParameters>]
   
    Update-Database [-SourceMigration <String>] [-TargetMigration <String>] [-Script] [-Force] [-ProjectName <String>] [-StartUp
    ProjectName <String>] [-ConfigurationTypeName <String>] -ConnectionString <String> -ConnectionProviderName <String> [<Common
    Parameters>]
   
   
DESCRIPTION
    Updates the database to the current model by applying pending migrations.
   

PARAMETERS
    -SourceMigration <String>
        Only valid with -Script. Specifies the name of a particular migration to use
        as the update’s starting point. If omitted, the last applied migration in
        the database will be used.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -TargetMigration <String>
        Specifies the name of a particular migration to update the database to. If
        omitted, the current model will be used.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -Script [<SwitchParameter>]
        Generate a SQL script rather than executing the pending changes directly.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -Force [<SwitchParameter>]
        Specifies that data loss is acceptable during automatic migration of the
        database.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -ProjectName <String>
        Specifies the project that contains the migration configuration type to be
        used. If omitted, the default project selected in package manager console
        is used.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -StartUpProjectName <String>
        Specifies the configuration file to use for named connection strings. If
        omitted, the specified project’s configuration file is used.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -ConfigurationTypeName <String>
        Specifies the migrations configuration to use. If omitted, migrations will
        attempt to locate a single migrations configuration type in the target
        project.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -ConnectionStringName <String>
        Specifies the name of a connection string to use from the application’s
        configuration file.
       
        Required?                    false
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -ConnectionString <String>
        Specifies the the connection string to use. If omitted, the context’s
        default connection will be used.
       
        Required?                    true
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    -ConnectionProviderName <String>
        Specifies the provider invariant name of the connection string.
       
        Required?                    true
        Position?                    named
        Default value               
        Accept pipeline input?       false
        Accept wildcard characters? 
       
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        "get-help about_commonparameters".

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

One thought on “EF Code First Migrations Update-Database Parameters Documentation?

  1. Hi Julie,

    I’m not sure if this is the correct place for this, but you had no comments here- so I’ll be the first.

    I have a view that uses a date field in the table to create a new field that replaces the day with 1 (all dates become MM/01/YYYY). This parses the pieces as varChar, and then is cast back to Date in SQL.

    The data type of the column shows Date, but when I add it to the .EDMX, it insists it’s a string. I can’t seem to find a why, or a work-around, even in your books.

    Any help or answers would be appreciated! (I am using the string in my code, but I just have to know why!)

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.