Invalid object name 'Entity'.

My first MSCRM 4.0 upgrade was last night, and so was my first MSCRM 4.0 issue. The issue, after upgrading MSCRM and accessing the site, was: "System.Data.SqlClient.SqlException: Invalid object name 'Entity'." A screenshot is attached to the post if you want to see it.

Straight away, you can see it is a SQL error, so I pulled up SQL Profiler to investigate. I first limited the trace to the _MSCRM and _METABASE databases (remember, this was an upgrade) and started monitoring the activity. What I noticed is that it was running a SELECT * FROM entity, so entity must be a table or view. However, checking the database myself revealed that it couldn’t be found, and running the statement manually also failed. I also noticed that _METABASE was not being accessed at all.

So, using Deployment Manager, I created a new tenant to compare. The first thing I noticed was that this new tenant had no _METABASE database—and, if I ran the same SELECT statement in this new tenant’s database, it worked. Digging deeper, I found a table named entity. But wait—what was before it? Normally, tables are prefixed by dbo, but this one wasn’t; instead, it was prefixed with something like metabase. Then I remembered my SQL Server 2005 training on schemas.

See, MSCRM 4.0 doesn’t need two databases anymore—it uses schemas to separate both the metabase and data within a single database, allowing for finer security control. This is also why SQL Server 2000 isn’t supported—it doesn’t have schemas (at least one of the reasons).

To resolve the issue, I ensured that the Network Service account (since we upgraded using that account) had the same permissions on the original database as on the new tenant database, and—voilà—it worked!

Attachments