Reputation: 359
I have a project where I'm using Fluent NHibernate to map an SQL Server database and I generate data from another Fluent NHibernate mapped SQL Server database which is our source.
I'm currently writing some unit tests which is to check the functions that read from one database and create records in the other. I've created an in-memory SQLite database of my db for creating records, and it works fine. But when I try to create a similar SQLite database for my "source" database I get failures which claim "no such table".
This seems to be because in the Fluent NHibernate dll for the source database they've given names like "dbo.table" and since there's no schema in my SQLite test database it's not able to create a test table.
Is there a way to handle this "dbo." name in SQLite when creating the test database?
Upvotes: 2
Views: 3362
Reputation: 259
You can pass a delegate to SchemaExport.Execute
to modify the script calls. Set the execute parameter to false and you can modify the lines of the script and call them yourself:
schemaExport.Execute(script =>
{
using (var cmd = session.Connection.CreateCommand())
{
cmd.CommandText = script.Replace("dbo.", "dbo_");
cmd.ExecuteNonQuery();
}
}, false, false, exportSchemaOutput);
(I'm assuming you have already invoked an ISession
object).
Upvotes: 0
Reputation: 180240
SELECT * from dbo.mytable
is the same as:
SELECT * from "dbo"."mytable"
To make that work, you would need to attach another database named dbo
, like this:
ATTACH DATABASE ':memory:' AS dbo
Alternatively, wrap the table names in quotes (if that is possible with NHibernate), so that the point is part of the table name:
SELECT * FROM "dbo.mytable"
Upvotes: 3