1

I'm using Entity Framework 4.2 in code-only "mode". I'm letting it autogenerate my database from the model.

However, it's adding spaces to my table and column names based on title-casing - e.g. a CustomerOrder class is mapped to a [Customer Orders] table and a ProductNumber property is mapped to a [Product Number] field.

Is there any way of preventing this from happening - short of configuring every table and property name via the Fluent API (which I know how to do)?

Is this a new 4.2 thing?

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
dommer
  • 19,610
  • 14
  • 75
  • 137
  • Hi... I could not reproduce this behavior with EF 4.2 CTP, that is the one I have here. Could you tell more about how to do this happen? – Miguel Angelo Nov 04 '11 at 21:46
  • Actually, I think it might be a third party library causing a side effect. I'm looking into this just now. It's an inherited application. – dommer Nov 04 '11 at 23:04

1 Answers1

1

You can override the OnModelCreating of your DataContext and change the conventions used by entity framework... there may be a convention of adding spaces before upper-case letters. Remove the convention and you are done.

The conventions are inside the modelBuilder object passed as argument to that method. It has a Conventions property that you can inspect, and see if the convention exists there.

Miguel Angelo
  • 23,796
  • 16
  • 59
  • 82
  • Thanks for responding. I had a look at the conventions list, but couldn't see an obvious one. Do you know which one it is? I've not noticed this before, so wondering if it's new. – dommer Nov 04 '11 at 21:14
  • I looked at Reflector to see all the convention types in the EntityFramework 4.2, but I found no one suggesting that it adds spaces, the only one convention about naming I found was `PluralizingTableNameConvention`. I am trying to reproduce this here... to see if the spaces thing show up here. – Miguel Angelo Nov 04 '11 at 21:22