Schema Referenced by Map has been deleted.

Had this issue a couple of times lately. A deployment from Visual Studio fails and then I get this error from the BizTalk Admin console.

Delete of ApplicationNode failed

Error while removing application XXX. (mscorlib)

Schema referenced by Map XX has been deleted. The local, cached version of the BizTalk Server group configuration is out of date. You must refresh the BizTalk Server group configuration before making further changes. (mscorlib) 


It’s very irritating as you can’t un-deploy or remove any of the resources. Searching the forums it seems most folks resolve it by re-configuring BizTalk which is a little extreme. It’s a weird error as I can see the schemas and maps deployed, keys haven’t changed neither has the version number so I’m not sure what it’s issue is.

Warning: Messing around in the BizTalkMgmtDb is risky stuff, take some backups before you do this.

It’s actually pretty easy to fix. You’ll need delete permissions on the BizTalkMgmtDb but the first step is to find the itemid from bts_item table in the management database.

FROM [BizTalkMgmtDb].[dbo].[bts_item]
where namespace = 'My.Map.NameSpace'
and Name = 'MapName'
Then delete the map from the bts_MapSpec table.
delete from dbo.bt_MapSpec
where itemid = 2140
You should now be able to either delete the whole application or remove the resources.