1

I am trying to find a best way to work using Entity Framework and found a recommendation to not have a big models (separate them by intent) because it can make application more complex to maintain and can have an impact on performance

According to Julie Lermans course at Pluralsight.com it is possible (and recommended) to separate models (contexts) using Code-First approach, but how can I do it using Model-First approach? Is it possible?

Any suggestions?

Prokurors
  • 2,458
  • 3
  • 40
  • 65

1 Answers1

1

Why not do it in Code First? It's a better way and gives you more control (at least my opinion :)) I'm not familiar with Model first approach but you need to have possibility to:

  • Map your entities to same database table even if they have not the exact same name.
  • Being able to setup a MigrationContext that you can use for Migration, since none of the other bounded context's do not have the full schema (if your intent is to have all bounded context's in one physical database)

if your Model first approach can do this. I see no problem with doing that.

Magnus Backeus
  • 2,242
  • 17
  • 24
  • Model-first gives me opportunity to design (visualy in designer) structure of my EF model (inheritance, associations, etc.), maybe I will switch to Code-first after I will feel more comfortable about this approach. And yes my intent was to have all bounded context's in one physical database – Prokurors Oct 11 '13 at 21:13
  • 1
    If you decide to go for Code First, which i prefer due to type safety mappings and no edmx file problems. But I do recommend to read Vaughn Vernons articles about aggregate modeling - It will help you model and you may need to be able to do relationships between aggregate entities without EF knowing about it. I mean that you create entity references through "pointers" and not using traditional EF navigation property relationships. See Vernons 3-part modeling articles – Magnus Backeus Oct 11 '13 at 21:50
  • OK, it doesn't seem there will be answer to my question... but your answer was useful, so i'll mark it as answer anyway. Thanks! – Prokurors Oct 18 '13 at 14:30
  • Thanks... And Let me know if you need any help with Code First Approach. – Magnus Backeus Oct 18 '13 at 14:37