none
Automatic Migration with EntityFramework.Migrations gives Error with Renaming but not with SqlMigrations RRS feed

  • Question

  • Im using EntityFramework and EntityFramework.Migrations to implement solution using Code-First and Automatic Migrations.

    Wherever i made a very simple test solution to test the Migrations capabilities and i`m stuck and renaming simple properties.

    i have this entity :

      public class Customer
        {
            public int Id { get; set; }
            public string FullName { get; set; }
            public string LastName { get; set; }
        }


    Now when i try to rename FullName to FirstName, I understand i have to use Update-Database with renames so i type this in the Console:

     Update-Database -Renames:"Customer.FullName=>Customer.FirstName"

    Now this used to work when i was using "SqlMigrations" but now that i Use "EntityFramework.Migrations" it doesn't work, it gives me this error:

    Update-Database : A parameter cannot be found that matches parameter name 'Renames'.
    At line:1 char:26
    + Update-Database -Renames: <<<< "Customer.FullName=>Customer.FirstName"
        + CategoryInfo          : InvalidArgument: (:) [Update-Database], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,System.Data.Entity.Migrations.UpdateDatabaseComma 
       nd


    So i bet its different in EntityFramework.Migrations, Im not sure what im doing wrong or what i should be doing...

    Here is Resources i have been reading about both:


    Monday, December 5, 2011 2:42 PM

Answers

  • Hi ZeusSE,

    Welcome!

    Based on my testing, there is not renames command in "Alpha" and EF4.2, you can use the command to see it:

    >>get-help update-database -full

    ------------------------------------

    SYNTAX
        Update-Database [-SourceMigration <string>] [-TargetMigration <string>] [-Script] [-Force] [-TargetDatabas
        e <string>] [-ProjectName <string>] [-ConfigurationType <string>] [-ConfigurationFile <string>] [<CommonPa
        rameters>]
       
       
    DESCRIPTION
        Updates the database to the current model by applying pending migrations.

    ------------------------------------

    The No-Migic Migration will Drop the Old column and add a new one.

    --Renames is only supported in "August 2011 CTP ", I'll consult the product team for the Rename function. Thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 6, 2011 8:30 AM
    Moderator

All replies

  • Hi ZeusSE,

    Welcome!

    Based on my testing, there is not renames command in "Alpha" and EF4.2, you can use the command to see it:

    >>get-help update-database -full

    ------------------------------------

    SYNTAX
        Update-Database [-SourceMigration <string>] [-TargetMigration <string>] [-Script] [-Force] [-TargetDatabas
        e <string>] [-ProjectName <string>] [-ConfigurationType <string>] [-ConfigurationFile <string>] [<CommonPa
        rameters>]
       
       
    DESCRIPTION
        Updates the database to the current model by applying pending migrations.

    ------------------------------------

    The No-Migic Migration will Drop the Old column and add a new one.

    --Renames is only supported in "August 2011 CTP ", I'll consult the product team for the Rename function. Thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 6, 2011 8:30 AM
    Moderator
  • hey Alan,

    Thanks for replying,

    yeah i figured out that "Renames" is not supported in the latest build, so any news about the replacement ?

    i mean it was a great feature i don't see why its removed, i hope there is a replacement for it,

    Please let me know.

     

    Wednesday, December 7, 2011 10:48 AM
  • Hi ZeusSE,

    Thanks for your feedback.

    I got the confirm from the Product Team.

    ---------------------

    If you rename the property in your class then you need to generate the code migration and replace the drop/create with a rename.

    ---------------------

    Thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 9, 2011 9:16 AM
    Moderator