Question

I'm currently working with a large database (approx. 500 tables) all without any foreign keys define.

My question is there an easy way to set up the relationships within entity framework (version 1 or 2) without doing it all manually?

Also some of the tables have a complex relationship type. For example a customer has a parentID but this can either link to another customer in the same table (customerID) or link to an account in an account table (accountID). Is this kind of relationship possible in entity framework?

If this is not possible or if anyone has any opinions on an alternative solution to Enitity Framework I'm more than open to ideas. Will nHibernate or active record be a better solution? Or will it be easier creating my own business object and data access?

Cheers

Simon

Was it helpful?

Solution

If you don't have any Foreign Keys defined, then there's no way for the Entity Framework to infer relationships. You'll have to define them manually.

As for your second question...no. That kind of relationship is not possible (it's also a poor design choice).

It sounds to me like, unless you want to refactor your database and implement a design that has Foreign Key relationships, you're going to have to hand roll your own Business Objects and Data Access Layer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top