entity framework - EF 5.0 Migrations on a reverse engineered database. Can't update model changes because the tables already exist -


i using beta 3 of ef power tools ef5.0 reverse engineer existing database.

when select "reverse engineer code first" project context menu, models , dbcontexts + mapping expected. , looks good.

i enabled migrations after reverse engineering process completed.

however want add new property 1 of models. after adding new property,

i run pm> add-migration addmypropertytomytable

a migration file created,

if try pm> update-database

i error telling me tables exist.

i following tutorial here:> http://msdn.microsoft.com/en-us/data/jj200620

why getting error? of course table exists, reverse engineered it

am supposed delete database after reverse engineering? or in case of reverse engineered db, have make changes actual database , reveres engineer again desired changes in project (so what's point of reverse engineering in first place?)

is there missing tutorial, i.e. step required make database updateable after model changes?

when enabled migrations existing database, ef didn't add __migrationhistory table or initial migration (dbmigration) file.

you can add initial migration using following in package manager console:

add-migration initial -ignorechanges 

this empty initial migration. force ef create __migrationhistory table, can use:

update-database 

this should create __migrationhistory table (under system tables)

you should able make model changes, , create new migration files (or use automatic migrations configuring in configuration.cs file under migrations folder).

you can run these migration changes hand using update-database, or have database automatically migrated latest migration on application startup using migratedatabasetolatestversion initializer.

you can set in app.config/web.config isn't set in production example.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -