ENABLE MIGRATION

Enables Migrations by scaffolding a migrations configuration class in the project. If the  target database was created by an initializer, an initial migration will be created unless  automatic migrations are enabled via the EnableAutomaticMigrations parameter).

 

OPEN PACKAGE MANAGER CONSOLE in Visual Studio (TOOLS>Library Package Manager  > Package Manager Console)

SYNOPSIS

Enables Code First Migrations in a project.

SYNTAX

Enable-Migrations

[-ContextTypeName <String>]

[-EnableAutomaticMigrations]

[-ProjectName <String>]

[-StartUpProjectName <String>]

[-ConnectionStringName <String>]

[-Force]

[<CommonParameters>]

 

Enable-Migrations

[-ContextTypeName <String>]

[-EnableAutomaticMigrations]

[-ProjectName <String>]

[-StartUpProjectName <String>]

-ConnectionString <String>

-ConnectionProviderName <String>

[-Force] [<CommonParameters>]

DESCRIPTION

Enables Migrations by scaffolding a migrations configuration class in the project. If the  target database was created by an initializer, an initial migration will be created unless  automatic migrations are enabled via the EnableAutomaticMigrations parameter).

 

PARAMETERS

    -ContextTypeName <String>

Specifies the context to use. If omitted, migrations will attempt to locate a single context type in the target project.

        Required?                    false

        Position?                    named

        Default value

        Accept pipeline input?       false

        Accept wildcard characters?

    -EnableAutomaticMigrations [<SwitchParameter>]

Specifies whether automatic migrations will be enabled in the scaffolded migrations  configuration.

If ommitted, automatic migrations will be disabled.

Required?                    false

Position?                    named

Default value

Accept pipeline input?       false

Accept wildcard characters?

    -ProjectName <String>

Specifies the project that the scaffolded migrations configuration class will  be added to. 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?

 

    -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?

 

    -Force [<SwitchParameter>]

        Specifies that the migrations configuration be overwritten when running more

        than once for a given project.

        Required?                    false

        Position?                    named

        Default value

        Accept pipeline input?       false

        Accept wildcard characters?

 

 

 

 

 EX: 

Enable-Migrations

-ConnectionString:””

-ConnectionProviderName:”” 

-ProjectName:”” 

-StartUpProjectName:””

-ContextTypeName:””

-EnableAutomaticMigrations 

 

 

 

Enjoy!!

 

 

 

Advertisements