-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SchemaExport not pluralizing Table Names
PostPosted: Fri Jun 04, 2010 12:43 pm 
Newbie

Joined: Fri Jun 04, 2010 12:33 pm
Posts: 2
I posted this at StackOverflow and got no response, so maybe this is a better place:

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:


Code:
   
        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:

Code:
        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.

*Late Note: This seems to happen w/SQL Server as well. I thought it had been working properly w/SQL Server before, but I could be wrong about that.


Top
 Profile  
 
 Post subject: Re: SchemaExport not pluralizing Table Names
PostPosted: Fri Jun 04, 2010 3:25 pm 
Newbie

Joined: Fri Jun 04, 2010 12:33 pm
Posts: 2
Well, I'm not sure why this made a difference, but in the process of debugging, I did this, and now it works:
Code:
        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));
        }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.