views:

149

answers:

1

Is it possible in EF4 to change conventions for a whole DbContext rather than on a per entity basis?

Currently when I run EF4 queries I'm getting an error on foreign key relationships

Invalid column name 'Account_Id'.

The table being queried (User) has a column named AccountId which is a foreign key to the related table (Account), if I change the column to Account_Id, it solves the problem.

However, the issue is that I don't want to do this on every table. I've set custom conventions no problem using NHibernate, so hopefully its as simple in EF4.

+1  A: 

I don't think there is support for global settings. You can use fluent API, as you probably know, but this works for single entity only. I've decided to keep EF4 conventions and use xxxID for primary keys and table1_table2 for linker tables. It's easier to swim with, not against the current ;-). You might want to fire reflector to check the code for an easy way to hack it...

Jakub Konecki