none
Error in Migrations EF RRS feed

  • Question

  • Hello all,

    I have a blank database and running my project for the 1st time.
    However when I run my project, I got a error message:

    Additional information: Migrations is enabled for context 'SiteContext' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console.

    Whats going on ?
    I have done Update-migration, deleting everything and running enable-migrations, etc, but doesnt work.

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

    using (var db = new SiteContext())
                {
                    var user = new UserAccess() { TypedEmail = "myemail@my.com" };
                    db.UsersAccess.Add(user );
                    db.SaveChanges();
                }

    Tuesday, February 11, 2014 9:28 PM

Answers

  • Hello,

    >>I have a blank database and running my project for the 1st time.

    Being strange that if it is that you are using Code First, it should not have a database before running the program for the 1<sup>st</sup> time.

    Have a try to delete both the database and the migration folder and then run the program again.

    If it throws the error again, please provide the SiteContext class codes, and if it is that you use the PCM command to migrate the database or use the DataBaseInitiative<>(new XXXX).

    If you want to know more regarding it, referring to link below:

    http://msdn.microsoft.com/en-us/data/jj591621.aspx

    http://msdn.microsoft.com/en-us/data/jj554735.aspx

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, February 12, 2014 9:10 AM
    Moderator