c# - Continuous delivery and database schema changes with entity framework -


we want progress towards being able continuous delivery of of our application production. deploy azure , use table/blob storage , have azure sql database, access entity.

as database schema changes want able automatically apply schema changes production database, happen whilst application live , code changes being deployed many nodes @ same time not sure correct approach is.

after reading seems (and makes sense) application needs tolerant of 2 different database schema versions, doesn't matter if old version of code or new version of code sees database, i'm not sure best way approach handling in application is, using entity framework.

should have versioned instances of ef generated classes in code know how access specific version of schema? happens when schema updated , old version of code running against database?

our entity framework classes mapped views in specific schemas in db , nothing mapped underlying tables, potentially allow create v1 views old code uses , v2 views new code uses, maintaining feels bit of nightmare (its enough of pain maintaining ef mappings views rather tables)

so best practices in area? others solve problem?

whether use ef or not, maintaining code's ability work 2 consecutive versions of database (and perhaps viable) approach here.

here ways handle specific types of migrations:

  • when adding column, can typically add column (with default constraint if non-nullable) , not worry code. ef never issue "select *", able continue function while ignoring new column. similarly, adding table easy.

  • when removing column or table, keep column around 1 version longer have otherwise.

  • for more complex migrations (e. g. changing structure table or segment of data model), deploy new model alongside backwards-compatibility views (or tables triggers keep them in-sync), live long code references them. say, can lot of work depending on complexity of migration, sounds well-positioned because ef entities point views anyway. on other hand, benefit of work have more time code migration. if have large codebase, beneficial in allowing migrate data model fit needs of new features while still supporting old features without major code changes.

as side-note, difficulty of data migration makes push developing finalized data model far possible in development schedule. ef, can write , test lot of code before data model finalized (we use code-first generate sample sqlexpress database in unit tests, though our production database not maintained code-first). way, make fewer incremental changes production data model once new feature released.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -