views:

59

answers:

2

I've got an ASP.NET MVC (VB) project with two models that represent two different databases. Each model needs to include a table from its database with the same name. For example, model1.dbml needs to have db1.MyTable in it, and model2.dbml needs to have db2.MyTable in it.

I can't do this because both models try to create a "Partial Public Class MyTable", and both have "Public Sub New()", so you get the "multiple definitions with identical signatures" error.

There is a potential for a number of the tables between the models to have the same name. (These are separate instances of the same product used for different lines of business.) How do you get around this? Do I have to change every one of the names in one of the models to be unique? Is there a better way?

+1  A: 
Daniel A. White
+1  A: 

There is a code smell to this. If your two databases are really two separate and distinct entities, then why are they in the same project; and if they are not two separate entities, then why are there two separate databases?

If you are working with one application in a portal configuration (multiple companies), then the separation can take place using a CompanyID field as a filter, and there is only ONE set of entity classes needed.

Robert Harvey
you are right, this is a Design or Naming issue
Rony
What we have is two similar databases for two product lines, but each has subtle differences (third-party apps customized to each product line), so they don't map neatly to the same model. They are in the same project because the data being extracted is the same, but extracted from each in different ways.
gfrizzle
Can you separate them by ProductLineID, in thoses classes that are identical? If the classes are not identical, I believe they should have different names.
Robert Harvey
Cool beans if you can change the context to solve the problem.
Robert Harvey