We did a 3.x to 3.5 upgrade this week on one of our existing websites, and ran into some pain. On of our other developers spent 4 hours working on it, which in fairness is partly because we have our own customizations in the site. However, he got stuck on one particular error. The error could have easily been avoided if you would just NORMALIZE YOUR DATABASE. Its really not that hard and would help us developers greatly. I'm not sure if its your developers that don't normalize certain things or if its Nolics itself, but not normalizing means more room for these types of errors and more data that has to be touched when somethings changed. Below are the steps I as the lead developer had to go thru to debug and correct this problem:
So the other developer was
getting this error related to the Sitefinity upgrade that said “Key not found
for value UpcommingEvent.”
misspelled so i figured the error was related to the Sitefinity developers correcting the spelling.
through the stack trace, I saw it was trying to parse this value from into an enum and
not finding that string in the enum thus throwing the error.
the code had been completely replaced by the new version (3.5) I assumed the problem had
to be in the database.
like 100+ something tables in Sitefinity, so going thru them one by one was out
of the question.
I opened up
sql profiler, ran the page again and collected all the generated queries to the
database from sitefinity.
the queries mentioned “UpcommingEvent” so instead I ran all the queries that
profiler found and looked at the results.
the query results from grid view to text view in sql management studio.
I then did
a find for UpcommingEvents, and found the text!
I found the query that got that result to find the table and column holding that
event, something like "sf_cmscontrolproperty" and "value".
I did a
LIKE search on that table and column to find all the records that had “UpcommingEvents”. 19 records had this text in it!
what the right value was to put in there, I did a search in vs.net in object
browser for anything that had “Upcoming” (spelled correctly) in the hopes I
would find an enum with this value and that this would be the correct value.
there WAS an enum and it had 3 values, something like PastEvents,
CurrentEvents, UpcomingEvents (spelled correctly.)
the exact enum value into sql query analyzer and updated the 19 records from “UpcommingEvents”
I ran the
site again, and it was fixed.
This took over an hour.
If the database had been normalized, with just the value of the enum (the integer) in the database, this could have been avoided. You could have changed the names of the enums without hurting the data at all, as long as you didn't change the underlying values.
Anytime you see repeating data (in this case "UpcommingEvents" your breaking normalization and creating work for yourselves and/or your customers. 3NF has been around for a long time, I'm not sure why so some people choose not to use it when it prevents a slew of problems. Its okay to denormalize certain data thats non-authoratative and can be recreated from normalized data (such as for reporting) but this wasn't the case.