3

I'm following a database first approach in this example. Because of the manageability issue of a single edmx, I have decided to break down the single edmx to multiple edmxs.

I created a project and added a new ADO.net Entity Data Model called AModel. It gave me the option of Choosing DBNameEntities for Save Entity connection string in the App.config. As a result the context is generated as:

public partial class DBNameEntities : DbContext

Now I added another ADO.net Entity Data Model called BModel. I gave the option of selecting DBNameEntities1 as a connection string for 'Save Entity connection string in the App.config'. Since I have already a connecting string which I created for the AModel, I deselected the option for the connection string. Now the context for BModel is generated as (POCO entities generated from the T4 template):

public partial class Entities : DbContext

  1. In a single project, is it okay to use multiple dbContexts (DBNameEntities, Entities) for multiple models?

  2. Or In a single project, is it advisable to use only single dbContext but break down the models into many with different edmxs?

  3. How can I use the same connection string called DBNameEntities for multiple models but at the same time create meaningful contexts. I wanted the context for BModel is generated as BContext and the context for AModel is generated as AContext. eg. public partial class AContext : DbContext

  4. Is the right approach to solving my problem, to create different projects and each project have a model rather than using a single project to have multiple edmxs.

Share your ideas.

wonderful world
  • 10,969
  • 20
  • 97
  • 194
  • 1
    In VS2012 you can have multiple views of the same model. Maybe this would be easier than having multiple edmx files/projects? – Pawel Jan 28 '13 at 02:59
  • I found out this link where the author is [talking about](http://blogs.msdn.com/b/adonet/archive/2008/11/24/working-with-large-models-in-entity-framework-part-1.aspx?wa=wsignin1.0) using multiple edmxs. – wonderful world Apr 02 '13 at 11:16

0 Answers0