Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6358877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:26:41+00:00 2026-05-24T23:26:41+00:00

I’m trying to set up SQLite for unit testing with Fluent NHibernate as shown

  • 0

I’m trying to set up SQLite for unit testing with Fluent NHibernate as shown here but the table names isn’t being generated as I expected.

Some tables have schemas with dots inside which seems to break the generation. (Dots works perfectly well with Microsoft SQL Server which I have in my production environment.)

Example:

[Foo.Bar.Schema].[TableName]

Result:

TestFixture failed: System.Data.SQLite.SQLiteException : SQLite error
unknown database Foo

How do I instruct SQLite to translate the dots to underscores or something so I can run my unit tests?

(I’ve tried adding brackets to the schema names with no success)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:26:42+00:00Added an answer on May 24, 2026 at 11:26 pm

    You can use a convention
    http://wiki.fluentnhibernate.org/Conventions

    *UPDATED

    public static class PrivatePropertyHelper
        {
            // from http://stackoverflow.com/questions/1565734/is-it-possible-to-set-private-property-via-reflection
            public static T GetPrivatePropertyValue<T>(this object obj, string propName)
            {
                if (obj == null) throw new ArgumentNullException("obj");
                PropertyInfo pi = obj.GetType().GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                if (pi == null) throw new ArgumentOutOfRangeException("propName", string.Format("Property {0} was not found in Type {1}", propName, obj.GetType().FullName));
                return (T)pi.GetValue(obj, null);
            }
        }
    
    public class CustomTableNameConvention : IClassConvention
    {
        // Use this to set schema to specific value
        public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
        {
            instance.Schema("My_NEw_Schema");
            instance.Table(instance.EntityType.Name.CamelToUnderscoreLower());
        }
    
    
        // Use this to alter the existing schema value.
        // note that Schema is a private property and you need reflection to get it
        public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
        {          
            instance.Schema(instance.GetPrivatePropertyValue<string>("Schema").Replace(".", "_"));
            instance.Table(instance.EntityType.Name.CamelToUnderscoreLower());
        }
    }
    

    You must use only one of he Apply methods.

    *UPDATE 2
    I don’t know I would recommend this but if you like to experiment this seems to work. Even more reflection 🙂

        public static void SetSchemaValue(this object obj, string schema)
        {
    
            var mapping_ref  = obj.GetType().GetField("mapping", BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.GetField | BindingFlags.NonPublic).GetValue(obj);
    
            var mapping = mapping_ref as ClassMapping;
            if (mapping != null)
            {
                mapping.Schema = schema;
            }
        }
    
    
        public void Apply(FluentNHibernate.Conventions.Instances.IClassInstance instance)
        {
            var schema = instance.GetPrivatePropertyValue<string>("Schema");
            if (schema == null)
            {
                instance.Schema("My_New_Schema");
            }
            else
            {
                instance.SetSchemaValue("My_New_Schema");
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.