0

I have taken over maintenance of a legacy application which manages projects each of which has a separate database (identical for the purposes of this question) there are currently > 1000 databases. In addition, these databases do not have table relationships defined, instead the relationships are determined using joins at the query level. Data is currently extracted using dynamic SQL and ADO.net.

I had hoped to use Entity Framework to provide a common data access layer, switching between databases using a different connection string as required

However I'm now thinking that due to the lack of table relationships (it is not even clear which are 1 to many, 1 to 1 etc.) EF may be more trouble than its worth, I will have troubles defining associations and navigation properties which will make the task of extracting data much more complex.

My question is, does that sound like a fair assessment? Or would Entity Framework be fine in the above scenario?

Community
  • 1
  • 1
majjam
  • 1,286
  • 2
  • 15
  • 32
  • 1
    _"these databases do not have table relationships defined...EF may be more trouble than its worth"_ - With a _database-first_ scenario (as opposed to _code-first_), EF does require that the DB be already setup with database-level relationships prior to generating a .NET EF code model if your intent is to have `associations and navigation properties`. Yes I would agree with you there about EF not being suitable. –  Mar 31 '15 at 10:40
  • Thanks Micky, do you think that a code first approach could work? – majjam Mar 31 '15 at 11:00
  • Well you could. However it sounds like it might be much work re-creating all the classes by hand, but at least that way you can define the navigation properties thus making your actual app code easier. Just be careful it doesn't try to re-write your DB schema. –  Mar 31 '15 at 11:04
  • Thanks for the warning o_O I think that, following your advice I'll leave it as ADO.net and save EF for this app's eventual replacement. – majjam Mar 31 '15 at 11:06
  • 1
    I recommend looking into Dapper. It's a micro-ORM that is very flexible. I've used it with great success. –  Mar 31 '15 at 14:41

0 Answers0