This project is read-only.

Issues after migrating database - null id in Orchard.ContentManagement.Records.ContentItemRecord entry

Topics: Troubleshooting
Oct 5, 2013 at 8:34 PM
Edited Oct 5, 2013 at 8:35 PM

I am developing a site in Orchard and all was well....

I had to move my database so I created a new one locally, gave it the same user/login details etc and updated my settings.txt connection string.

Managed to get this up and running and the site now runs from my local SQL server.

However, If I now try to create/save anything in the dashboard I get the following error:
null id in Orchard.ContentManagement.Records.ContentItemRecord entry  (don't flush the Session after an exception occurs)
A snippet from the error log gives me this:
2013-10-05 15:32:25,188 [32] Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught
NHibernate.Exceptions.GenericADOException: could not insert: [Orchard.ContentManagement.Records.ContentItemRecord][SQL: INSERT INTO Orchard_Framework_ContentItemRecord (Data, ContentType_id) VALUES (?, ?); select SCOPE_IDENTITY()] ---> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Id', table 'performance.performance.Orchard_Framework_ContentItemRecord'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Clearly something went a little wrong with my migration though I can't seem to figure out what...

I have also tried deleting the mappings.bin file in my app_data/sites/default folder - this didn't cure the issue either.

Any ideas?

Please do let me know if you need a little more information - thanks in advance :)
Oct 5, 2013 at 10:54 PM
How did you do the database migration? It look like only the data was moved, but not identity columns.
Oct 5, 2013 at 11:00 PM

I did it quick-and-dirty; export data in SQL to an SQL Express as trying to go from a shared-host DB to my own local Sql Express wouldn't work with SQL Copy Database

I just took a quick look at the exported version and it looks like you're pretty much spot on. The ID's were exported, though only as an int(not null) - the PK's weren't set.

Have to grab myself a trial of red-gate i guess :D

Thanks BertrandLeRoy
Oct 6, 2013 at 5:47 AM
Copy database maybe not, but backup should probably work. There are many ways to move databases around. I'm sure you can find one that will work.