Answered EF 4.3 migration error on Enable-Migrations

  • Saturday, February 11, 2012 8:28 PM
     
      Has Code

    I am following the EF blogs posted here to generate migration for my database.

    When I am run Enable-Migration -Force -Verbose against my data model, it  created the configuration class for me in migration folder, however , it didn't create the initial base migration for me. I received the following error 

    No migrations configuration type was found in the assembly '**** my assembly name'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
    

    Any idea what I am missing here.

Answers

  • Monday, February 13, 2012 8:11 AM
    Moderator
     
     Answered Has Code

    Hi John,

    Welcome!

    You should create your database firstly. In the link the code for create database:

     using (var db = new BlogContext())
                {
                    db.Blogs.Add(new Blog { Name = "Another Blog " });
                    db.SaveChanges();
    
                    foreach (var blog in db.Blogs)
                    {
                        Console.WriteLine(blog.Name);
                    }
                }
    

    then--"Enable-Migrations"

    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.

    • Marked As Answer by John Sun Wednesday, February 15, 2012 3:47 PM
    •  

All Replies

  • Monday, February 13, 2012 8:11 AM
    Moderator
     
     Answered Has Code

    Hi John,

    Welcome!

    You should create your database firstly. In the link the code for create database:

     using (var db = new BlogContext())
                {
                    db.Blogs.Add(new Blog { Name = "Another Blog " });
                    db.SaveChanges();
    
                    foreach (var blog in db.Blogs)
                    {
                        Console.WriteLine(blog.Name);
                    }
                }
    

    then--"Enable-Migrations"

    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.

    • Marked As Answer by John Sun Wednesday, February 15, 2012 3:47 PM
    •  
  • Wednesday, February 15, 2012 8:18 AM
    Moderator
     
     

    Hi,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?
    If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.

    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.