This project is read-only.

Error while running the code for the first time


HI , I see an error while running this code first time ..

Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

->With this i have made a change to..... public Configuration()
        AutomaticMigrationsEnabled = true; // from true to false;
-> Even i see an other error :
The operation failed because an index or statistics with name 'IX_RestaurantId' already exists on table 'dbo.RestaurantReviews'.

Here is webconfig file connection string details :

<add name="OdeToFoodDB2" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=OdeToFoodDb;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\OdeToFoodDb.mdf" providerName="System.Data.SqlClient" />

Please help me out from this issue to run the code .
I am eagerly waiting for your response..


OdeToCode wrote Sep 3, 2014 at 3:38 PM

I'm not sure what the state of the database is on your machine, but it sounds like the migrations are out of sync. Can you delete the database and run "update-database" from the package manager console to recreate the database in a fresh state?