I have two databases on one machine that also has two different sites running on IIS. Lets call them Site1 & Site2 and DB1 & DB2. The second site and BD are copys of the first one. The Site2 connects to DB2 and everything seems to work nice but when we took offline the DB1 it stoped working which is wierd since all the data created using the site2 was in DB2. In fact most of the site works except for one method
We use entity framework to access the database and when we trace the code everything looks ok, but it somehow doesn’t work.
In our auto-generated code by entity framework we traced the connectiong string and the outcome is correct
Initial Catalog=DB2;
But in the next line we have this code
return ((IObjectContextAdapter) this).ObjectContext.ExecuteFunction<T_REFERENCE_DATA>(
"GetReferenceData", groupNameParameter);
And we get an inner exception that says:
Database 'DB1' cannot be opened because it is offline.
All the other methods seem to use the correct database except this one. We can’t figure out where the DB1 is configured or hardcoded
The problem was (as usual) stupid as hell. Some of the guys defined the DB on the stored procedures. When we changed DB and copied the stored procedures they kept using the old DB. It is now fixed.
Thanks for your help