entity framework - EF 6.1.3 automatic migrations -


i created initial migration database when executed database operation via code first.

all tables got created successfully.

i have enabled automatic migrations.

i've added couple of columns model.

when run "update-database –verbose", error message (which understand, don't why it's coming out) of "there object named 'categories' in database."

the categories table along rest of tables got created on initial migration (as explained above).

i made change (adding 2 other columns) model (customer).

i think, code first migration @ entire dbset model, determine changed, apply necessary sql. instead, it's trying create categories table again exists.

can please explain me how can update db without happening? doing wrong or need in order work....

edit

successful creation of ef code-first migrations setup:

  • enable-migrations -enableautomaticmigrations
    • add-migration initial (creates _initial.cs file).
    • comment out code in _initial.cs file within migrations folder code don't want execute after initial db run create tables.
    • set configuration.cs file public access
    • add following code in global.asax file
     database.setinitializer(new          migratedatabasetolatestversion()); 
  • update-database - verbose (for db changes)
    • set "automaticmigrationdatalossallowed = true;" in configuration.cs file within migrations folder. (for db changes)


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -