title: Fluent Nhibernate - how do i specify table schemas when auto generating tables in SQL CE 4
body: <p>I am using SQL CE as a database for running local and CI integration tests (normally our site runs on normal SQL server). We are using Fluent Nhibernate for our mapping and having it create our schema from our Mapclasses. There are only two classes with a one to many relationship between them. In our real database we use a non dbo schema. The code would not work with this real database at first until i added schema names to the Table() methods. However doing this broke the unit tests with the error...</p>
  
  <pre><code>System.Data.SqlServerCe.SqlCeException : There was an error parsing the query. [ Token line number = 1,Token line offset = 26,Token in error = User ]
  </code></pre>
  
  <p>These are the classes and associatad MapClasses (simplified of course)</p>
  
  <pre><code>    public class AffiliateApplicationRecord
  {
      public virtual int Id { get; private set; }
      public virtual string CompanyName { get; set; }
      public virtual UserRecord KeyContact { get; private set; }
  
      public AffiliateApplicationRecord()
      {
          DateReceived = DateTime.Now;
      }
  
      public virtual void AddKeyContact(UserRecord keyContactUser)
      {
          keyContactUser.Affilates.Add(this);
          KeyContact = keyContactUser;
      }
  }
  
  public class AffiliateApplicationRecordMap : ClassMap&lt;AffiliateApplicationRecord&gt;
  {
      public AffiliateApplicationRecordMap()
      {
          Schema("myschema");
          Table("Partner");
          Id(x =&gt; x.Id).GeneratedBy.Identity();
          Map(x =&gt; x.CompanyName, "Name");
                      References(x =&gt; x.KeyContact)
              .Cascade.All()
              .LazyLoad(Laziness.False)
              .Column("UserID");       
      }
  }
  
  public class UserRecord
  {
      public UserRecord()
      {
          Affilates = new List&lt;AffiliateApplicationRecord&gt;();
      }
  
      public virtual int Id { get; private set; }
      public virtual string Forename { get; set; }
      public virtual IList&lt;AffiliateApplicationRecord&gt; Affilates { get; set; }
  }
  
  public class UserRecordMap : ClassMap&lt;UserRecord&gt;
  {
      public UserRecordMap()
      {
          Schema("myschema");
          Table("[User]");//Square brackets required as user is a reserved word
          Id(x =&gt; x.Id).GeneratedBy.Identity();
          Map(x =&gt; x.Forename);
  
          HasMany(x =&gt; x.Affilates);
  
      }
  }
  </code></pre>
  
  <p>And here is the fluent configuraton i am using ....</p>
  
  <pre><code>      public static ISessionFactory CreateSessionFactory()
      {
          return Fluently.Configure()
              .Database(
                  MsSqlCeConfiguration.Standard
                      .Dialect&lt;MsSqlCe40Dialect&gt;()
                      .ConnectionString(ConnectionString)
                      .DefaultSchema("myschema"))
              .Mappings(m =&gt; m.FluentMappings.AddFromAssembly(typeof(AffiliateApplicationRecord).Assembly))
              .ExposeConfiguration(config =&gt; new SchemaExport(config).Create(false, true))
              .ExposeConfiguration(x =&gt; x.SetProperty("connection.release_mode", "on_close")) //This is included to deal with a SQLCE issue http://stackoverflow.com/questions/2361730/assertionfailure-null-identifier-fluentnh-sqlserverce
              .BuildSessionFactory();
  
      }
  </code></pre>
  
  <p>The documentation on this aspect of fluent is pretty weak so any help would be appreciated</p>