Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate Multiple Schemas using Fluent nHibernate
    text
    copied!<p>I'm a newbie to nHibernate, and Fluent nHibernate, and I'm having a great deal of trouble with some simple setup on something.</p> <pre><code> private static ISessionFactory CreateSessionFactory() { return FluentNHibernate.Cfg.Fluently.Configure() .Database( FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008 .ConnectionString(@"MultipleActiveResultSets=True;Data Source=.\SQLEXPRESS;Initial Catalog=nHibernate;Integrated Security=True;Pooling=False")) .Mappings(m =&gt; m.FluentMappings.AddFromAssemblyOf&lt;Program&gt;()) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); } private static void BuildSchema(NHibernate.Cfg.Configuration config) { // this NHibernate tool takes a configuration (with mapping info in) // and exports a database schema from it new SchemaExport(config) .Drop(false, true); new SchemaExport(config) .Create(false, true); } </code></pre> <p>This method (taken partially from their own samples) creates the database. That's all fine and good... </p> <p>But I have multiple schemas in my database, for instance..</p> <p><code>dbo</code>.</p> <pre><code>Sheets.Traits </code></pre> <p>Sheets is a schema. So on the <code>SheetsMap</code> class, I have...</p> <pre><code>public class SheetMap : ClassMap&lt;Sheet&gt; { public SheetMap() { Id(x =&gt; x.Id); HasManyToMany(x =&gt; x.Traits) .ParentKeyColumn("Sheet") .ChildKeyColumn("Trait") .Cascade.All() .Schema("Sheets") .Table("Traits"); Table("Sheets"); } } </code></pre> <p>But this throws an error at runtime. Any idea on what I should do? I'm really not understanding 99% of how this is all supposed to work. </p> <p>The error I receive is ...</p> <pre><code>An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail. {"The specified schema name \"Sheets\" either does not exist or you do not have permission to use it."} </code></pre> <p>Basically, I need to know how to have the builder create this schema when it is doing the script. That's pretty much where the problem is, I am sure.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload