Multiple EDM's In a Single Project

IanRyder

Well-known member
Joined
Sep 9, 2012
Messages
1,130
Location
Healing, NE Lincs, UK
Programming Experience
10+
Hi,

I am hoping that someone can give me some guidance when using multiple Entity Data Models (EDM?s) in a large project that I am needing to build. I am comfortable when using a single EDM but I seem to have got myself into a bit of a hole when trying to implement multiple EDM?s in a single project.

Simply put, I am using SQL Server which has multiple databases within that server and I need to design an application which will have the need to interact with various databases within that server. In principle I have created a Data Access Layer and in that layer I have added an EDM for each of the Databases that I need to interact with. The first EDM added fine but the second EDM has thrown a ton of errors all along the similar lines of:-

Method 'OnCustIDChanging' cannot be declared 'Partial' because only one method 'OnCustIDChanging' can be marked 'Partial'

There are various other errors but I guess that they are all going to follow along a similar theme of what I am doing wrong.

I can easily get round this by adding each EDM to a separate project which can then be referenced by the larger project but I was just wondering if there is something stupid that I have done wrong and whether there are some better principals I should be adopting when trying to add multiple EDM?s to a single project.

Thanks for any insight that anyone can provide.

Cheers,

Ian
 
Truth is you are probably not doing anything wrong. There is a bug that hits you when two different models have a table with the same name (or something similar). I have not seen this bug for a while though, I don't think it shows up when you add a new Linq-To-Sql class and drag objects from the database explorer in VS2013, even if it's twice the same database. The old wizard has always been buggy, I think that's why they got rid of it in 2013. The new method for creating the DBML is just much cleaner IMO. If you don't have access to 2012 or 2013, as you said you can work around the problem by putting each model in a separate project, however impractical.
 
Many thanks for the comments Herman. I am still in VS2010 for the moment and maybe that is the issue right there but the business is just moving to VS2013 licences as we speak so I will probably go with the work around for now and then give the single project concept another go when we have migrated to 2013.

Have a good day and cheers for the help.

Kind regards,

Ian
 
Back
Top