c# - EF6: Renaming namespace using Code First Migrations -


it possible me rename namespace of entire project (including of course: dbcontext class, migrations configuration classes, etc) without breaking or having recreate migrations?

say, have project myproject, namespace is

foo.myproject 

and configuration classes in

foo.myproject.migrations 

say want rename foo namespace bar, , of course configurations namespace be

bar.myproject.configurations 

is there correct way of doing , maintain current migrations still working? these ways involve manually editing ___migrationhistory table or something? (at glance see contextkey column, suspect should manually edit.)

yes, indeed need update contextkey in the__migrationhistory table. code:

update [dbo].[__migrationhistory]     set [contextkey] = 'new_namespace.migrations.configuration'  [contextkey] = 'old_namespace.migrations.configuration' 

a read on topic of renaming namespaces ef6:

http://jameschambers.com/2014/02/changing-the-namespace-with-entity-framework-6-0-code-first-databases/


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -