Your BuildSchema needs to be static because you're calling it from inside
your static CreateSessionFactory method.

On Wed, Aug 26, 2009 at 7:49 AM, Anthony Gatlin <[email protected]> wrote:

>
> I am attempting to generate a schema in SQL Server based on the
> getting started example on the fluent web site. I made some changes to
> the code to accommodate SQL Server instead of SQL Lite but I seem to
> have bumped up against a brick wall.
>
> When I attempt to build the code, I am receiving the following error.
>
> Error   1       An object reference is required for the non-static field,
> method, or property 'FluentExample.Program.BuildSchema
> (NHibernate.Cfg.Configuration)' C:\Code\FluentExample\FluentExample
> \Program.cs     96      42      FluentExample
>
>
> After Googling most every thing I could find, it appeared that this
> error might have something to do with the NHibernate.ByteCode.Castle.
> In the project, I basically just went ahead and referenced every thing
> that seemed to be related to NHibernate or Fluent. Here is a list of
> those references.
>
> Antlr3
> Castle.Core
> Castle.DynamicProxy2
> Fluent.NHibernate
> Iesi.Collections
> log4net
> NHibernate
> NHibernate.ByteCode.Castle
>
>
> Here is my code.
>
> private static ISessionFactory CreateSessionFactory()
>        {
>                return Fluently.Configure()
>                  .Database(MsSqlConfiguration.MsSql2008
>                  .ConnectionString(c => c.FromConnectionStringWithKey
> ("FluentDB"))
>                  .Cache(c => c
>                    .UseQueryCache()
>                    .ProviderClass<HashtableCacheProvider>())
>                  .ShowSql())
>                  .Mappings(m => m
>                    .FluentMappings.AddFromAssemblyOf<Program>())
>                    .ExposeConfiguration(BuildSchema)
>                  .BuildSessionFactory();
>        }
>
>        private void BuildSchema(Configuration cfg)
>        {
>            new SchemaExport(cfg).Create(false, true);
>        }
>
> Any ideas as to what I may be doing wrong?
>
> Thank you!
>
> Anthony
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to