Duplicating an Orchard CMS site & database.

Topics: Troubleshooting
Aug 23, 2012 at 4:32 AM
Edited Aug 23, 2012 at 4:46 AM

Hi All.

I'm trying to duplicate an Orchard CMS instance (v. in an live environment to another live environment (so that they're two separate sites).

I have duplicated all of the site files and the database.

I've edited the settings.txt to point to the duplicate database and deleted the cache.dat, aswell as mappings.bin. I've done several app pool recycles however I keep getting the following errors in the log.

NHibernate.Util.ADOExceptionReporter - Invalid object name 'Settings_ShellDescriptorRecord'.
Orchard.Environment.DefaultOrchardHost - A tenant could not be started: Default
NHibernate.ADOException: could not execute query[ SELECT top 2 this_.Id as Id62_0_, this_.SerialNumber as SerialNu2_62_0_ FROM Settings_ShellDescriptorRecord this_ WHERE 1=1 ]

The full stack from the log can be found here: http://pastebin.com/FXRb24Q1

I've had a search around but can't find an answer anywhere. As i mentioned above i'm trying to create an exact duplicate of the site.

Anyone know what I'm doing wrong? or can point me in the direction to do it properly?

Aug 23, 2012 at 4:47 AM

Can you open the database and check that the tables are there?

Aug 23, 2012 at 4:56 AM
Edited Aug 23, 2012 at 6:17 AM

I logged in with SQL Server Management Studio and all the tables are the same. I also did a data compare with visual studio and both databases are identical.

The only possible difference between the two is the database name, and user login (which was updated in the settings.txt).

Additionally, it might help to note that within SQL Server Management studio I can't perform that query either. 

Select * From Settings_ShellDescriptorRecord Fails with: Invalid object name 'Settings_ShellDescriptorRecord'. For it to work it has to be quantified with the username. e.g: - Select * From userName.Settings_ShellDescriptorRecord will work correctly.

Aug 23, 2012 at 8:42 AM

It seems something related to sql login/schema mapping. Is the login's default schema dbo or something else ? Who is the db owner ?

Aug 23, 2012 at 9:16 AM

It does look to be something schema mapping related, but to test this I restored the database to a local sql server and kept the username / database name exactly the same. In the settings.txt I only changed the connection string to point to the local machine rather than a remote server and still had the same issue.

As I copy pasted from the error message above, "FROM Settings_ShellDescriptorRecord". Orchard isn't looking for anything related to the schema by the looks of it?

So in theory it shouldn't matter?

Also the SuperAdministrator is the owner.

Aug 23, 2012 at 9:37 AM
Edited Aug 23, 2012 at 9:38 AM

Every db user as a notion of "default schema".

Be careful that even if you restore a db with sql users inside, if your other db user as a different SID (internal id) the login will not map. To check this, simply open db user properties and ensure the "login name" is not empty.

Beside, sql server allow prefixing tab by databasename.schema.object_name, so you should not see anything related to "userName" in the table name path... That's why I think there is something wrong with users/logins/schema/roles.

Are the tables created with dbo schema ? What are the db roles exactly ? who owns the db_owner role ?

Aug 24, 2012 at 11:02 AM


So after doing some reading the permissions were all wrong with the duplicate database, and the default schema for the new user was also wrong. After starting from scratch I've been able to get it resolved.

Thanks @styx31 for the help! Much appreciated.