views:

30

answers:

1

Hi,

I am working on an old database, that i do not want to touch or modify in any way if possible. I want to build a new application that uses it's data but the database has no actual relations despite having primary and foreign keys linking tables.

If i import these tables into an Entity Framework model and add the associations manually, will i be able to use things such as lazy loading and linq?

Many thanks, Kohan

+3  A: 

This is definitely possible. Entity Framework simply generates SQL queries containing joins or where clauses that reference columns that you define in your conceptual model as foreign keys. The generated SQL is directly executed by the database.

Primary and foreign keys are only in your database for referential integrity. As a very simple test you can execute a SQL statement directly in your database that joins two related tables that do not have a foreign key relationship. You'll see that the query simply works. Entity Framework does exactly the same when you correctly define the relationships in your model.

Ronald Wildenberg
And the same story applies to most ORMs as well.
Galilyou