entity framework - Locating Source of Migration -


i have project started using ef migrations.

there initial migration , additional, hand-edited migration defines indexed views. there no other migration.

i added single property 1 class. when create new schema, property created. however, cannot see why created, since property not mentioned in migration.

if search entire source code folder (with subfolders, .) mention of property name, not appear in ef migration code (it appears in class defined, , in few lines of code property accessed).

when set breakpoint @ beginning , end of up() method 2 existing migrations, can see table created without additional property initial migration (verified in ssms), , property not yet exist @ end of last up() migration. sometime after control leaves last migration, code creates column in database additional property.

to try , track down, hand-edited new property initial migration. now, after up() method last migration exits, sqlexception

column names in each table must unique. column name 'mynewproperty' in table 'dbo.mytable' specified more once.

in constructor dbcontext.

the stack trace shows code instantiating dbcontext.

how can track down additional migration coming from?

if not explicitly adding code-based migration new property (using add-migration), column being created can determined automatic migrations enabled.

automatic migrations allow entity framework automatically determine schema changes required represent changes made domain model, adding new column.

you wondering why still tries add new column after hand edit code-based migration add new column; each code-based migration there generated code-behind file (.designer.cs) contains string imigrationmetadata.target property, returns string snapshot of domain model after migration has been applied.

when edit migration file hand, target property still returns old string representation of domain, not contain new property; result of this, automatic migrations attempts add duplicate column.

the solution add new property domain use add-migration command add new code-based migration new property.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -