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?
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.