开发者

Entity Framework on a database without foreign keys

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 anothe开发者_运维百科r 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜