1

I've system that has a primary data model to perform most of the work.

The model has quite a few tables and with performance in mind when I came to add an administrative feature to the application I decided to use a second separate data model.

All works well until my second data model needs to access a table that is also in the primary data model. Now, from digging around I can see this can cause problems.

The two possible workaround I've come up with are to either:

  1. Put the data models in separate projects.
  2. Use views / stored procedures for accessing the table in question when required.

Method 1 seems the simpliest but I'm concerned about whether there would be any performance loss. Method 2 seems a bit messy and takes the point out of using EF.

Before I plump for using method 1, is there an easier work around that I could use?

Community
  • 1
  • 1
GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104

2 Answers2

2

In the end I decided to put the two data models into separate projects and I've there hasn't been any slowdown that I've been able to notice (I've not done any benchmarking but it's passed the perception test).

In one of her online tutorials EF guru Julie Lerman says that you should put your data model in a separate project anyway, so I don't think this has been a bad workaround.

GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104
1

I am working with 2 models in the same project, because I connect to 2 different databases. I have put different namespaces using "Custom Tool Namespace" on *.tt files but it is not necessary. It generally works, but it cannot handle situation when the entity (table) with the same name is in both models. When you save one model the entity with the same name is deleted from the second model.

Alt-WN
  • 81
  • 6