Table name conventions thwarted by defaults #223

Open
Trinition opened this Issue May 17, 2013 · 0 comments

Projects

None yet

1 participant

@Trinition

This issue originated as a discussion on the fluent nhibernate google group: https://groups.google.com/d/msg/fluent-nhibernate/ZgZwAYggeJY/eSPreHRWzhcJ

I believe this is new in Fluent NHibernate 1.3 due to this change: f3186cb#diff-156

As I understand it, the table name determination behavior should be this:

  1. If there is an explicitly set table name on a ClassMap, use that table name.
  2. Else, if there is a convention, use that convention's table name.
  3. Else, use a sensible default value (e.g. "MyEntity")

However, in practice, the logic isn't being honored in that order. I do not have an explicit table name on my Classmap, but I do have a convention. However, my convention is finding that there is already a table name implicitly set -- to the sensible default. That is, when I debug and watch my convention's criteria -- Is.Not.Set -- execute, it finds there is in fact a table name set, so my convention skips setting one. but that table name it found already set is the one from the sensible default!

So if you have a convention like this:

var myConvention = ConventionBuilder.Class.When(
            c => c.Expect(x => x.TableName, Is.Not.Set),
            x => x.Table(string.Format("tbl{0}s", x.EntityType.Name)));

...and a ClassMap like this:

public class EventMap : ClassMap<Event> {} // No explicit table name set

...then the default table name for this class mapping should be "tblEvents". However, the actual table name determined at runtime is "Events", not "tblEvents". I'm fairly certain this originates from the "default" being applied and NOT overridden by the convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment