views:

131

answers:

1

I am using SQLite as my db during development, and I want to postpone actually creating a final database until my domains are fully mapped. So I have this in my Global.asax.cs file:

        private void InitializeNHibernateSession()
        {
            Configuration cfg = NHibernateSession.Init(
                webSessionStorage,
                new [] { Server.MapPath("~/bin/MyNamespace.Data.dll") },
                new AutoPersistenceModelGenerator().Generate(),
                Server.MapPath("~/NHibernate.config"));

            if (ConfigurationManager.AppSettings["DbGen"] == "true")
            {
                var export = new SchemaExport(cfg);
                export.Execute(true, true, false, NHibernateSession.Current.Connection, File.CreateText(@"DDL.sql"));
            }
        }

The AutoPersistenceModelGenerator hooks up the various conventions, including a TableNameConvention like so:

        public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
        {
            instance.Table(Inflector.Net.Inflector.Pluralize(instance.EntityType.Name));
        }

This is working nicely execpt that the sqlite db generated does not have pluralized table names.

Any idea what I'm missing?

Thanks.

A: 

Well, I'm not sure why this made a difference, but in the process of debugging, I did this, and now it works:

        public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
        {
            string tablename = Inflector.Net.Inflector.Pluralize(instance.EntityType.Name);
            instance.Table(tablename);
            System.Diagnostics.Debug.WriteLine(string.Format("Table = {0}", instance.TableName));
        }
sydneyos