Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modular concept with entity framework code first and self-contained migration support for each module

i would like to have a modular webapp as this example:

appCore:

  • contains [dbContext-instance, core-tables, core-data, ...]

appModuleA:

  • requires [appCore]

  • contains [moduleA-tables, moduleA-data, moduleA-logic, usage of appCore ...]

appModuleB:

  • requires [appCore, appModuleA]

  • contains [moduleB-tables, moduleB-data, moduleB-logic, usage of appCore AND moduleA ...]

etc.

dynamic loading of entities is no problem and i solved this problem as described here: http://romiller.com/2012/03/26/dynamically-building-a-model-with-code-first/

but how can i implement a migration support of each module without using AutomaticMigrationEnabled = true?

I hope I have formulated my problem understandable. :-)

thank you.

like image 903
Ali Ramezani Avatar asked Apr 23 '26 02:04

Ali Ramezani


1 Answers

You can use:

  • ONE LARGE CONTEXT
    with all tables declared

or 3 contexts

  • CORE
  • MODULE A ONLY
  • MODULE B Only

You can even add other unrelated tables to the DB manually.

However dont try and OVERLAP contexts for MIGRATION purposes. (Preferred initializer)

Contexts that overlap for data access purposes , no problem. (Initializer NUll)

Search for topic: Bounded Contexts and Entity Framework

like image 120
phil soady Avatar answered Apr 24 '26 23:04

phil soady



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!