Support Thread

Dbownerprefix Key

Dbownerprefix Key — APG vNext Guide

Dbownerprefix Key — a configuration and setup topic from the APG vNext support community.

Key Configuration Points

  • IIS App Pool: .NET 4.0 Integrated Pipeline mode is required.
  • Connection String: Verify SQL Server name, database, and credentials in web.config.
  • File Permissions: App pool identity needs read/write on the upfiles folder.
  • URL Rewriting: Install IIS URL Rewrite 2.0 module for clean SEO-friendly URLs.
  • Full-Text Search: Enable SQL Server Full-Text Indexing for forum search.

More Help

The DBOwnerPrefix Key in APG vNext web.config

The APG.DBOwnerPrefix key tells APG vNext which schema prefix to prepend to all database object names when building SQL queries. It defaults to "dbo." which is correct for most SQL Server installations. When APG tables are in a different schema, or when the database login doesn't have access to the dbo schema, this setting must be updated.

When You Need to Change It

  • Shared hosting where tables were created under a named schema (e.g. "forumuser.")
  • Enterprise SQL Server with schema-based access control
  • "Invalid object name 'dbo.apg_Members'" errors in the error log
  • After running the setup script under a non-dbo user

Configuration

<!-- web.config -->
<add key="APG.DBOwnerPrefix" value="dbo." />

<!-- For custom schema: -->
<add key="APG.DBOwnerPrefix" value="forumschema." />

<!-- For no schema prefix (not recommended): -->
<add key="APG.DBOwnerPrefix" value="" />

Diagnosing the Issue

-- Find actual schema of APG tables:
SELECT TABLE_SCHEMA + '.' AS DBOwnerPrefix
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_NAME = 'apg_Members';

Note on Stored Procedures

APG vNext uses a mix of direct table queries and stored procedures. Ensure stored procedures are in the same schema as the tables, or the prefix won't work for all operations.

Schema Prefix Impact on Stored Procedures and Views

The APG.DBOwnerPrefix key affects not just direct table queries but also stored procedure and view references within APG vNext's internal SQL. When APG vNext calls a stored procedure, it prepends the DBOwnerPrefix to the procedure name. If the stored procedures were created under a different schema than your current prefix setting, every stored procedure call will fail with an object not found error. This is the most common cause of silent failures after moving an APG vNext database to a different server or changing the database owner.

-- Verify all stored procedures are in the expected schema:
SELECT ROUTINE_SCHEMA + '.' AS SchemaPrefix,
       COUNT(*) AS ProcedureCount
FROM   INFORMATION_SCHEMA.ROUTINES
WHERE  ROUTINE_TYPE = 'PROCEDURE'
  AND  ROUTINE_NAME LIKE 'apg_%'
GROUP  BY ROUTINE_SCHEMA;
-- This should return exactly one row matching your APG.DBOwnerPrefix setting

Multi-Tenant Setups and Schema Isolation

In rare multi-tenant deployments where multiple APG vNext instances share a single SQL Server database (not recommended but sometimes necessary on shared hosting), each instance can be isolated in its own schema by using a unique prefix for each installation. Instance A uses prefix forum1., Instance B uses prefix forum2., and each has its own set of apg_ tables under that schema. The APG.DBOwnerPrefix key in each installation's web.config ensures queries are routed to the correct schema:

<!-- Instance A web.config: -->
<add key="APG.DBOwnerPrefix" value="forum1." />

<!-- Instance B web.config: -->
<add key="APG.DBOwnerPrefix" value="forum2." />

<!-- Create schema-isolated tables:
CREATE SCHEMA forum1;
CREATE SCHEMA forum2;
-- Run install scripts as forum1/forum2 user respectively -->

Common Errors Caused by Incorrect DBOwnerPrefix

Error: Invalid object name 'dbo.apg_Members'

This means the tables are in a different schema. Run the diagnostic query above to find the correct prefix and update web.config accordingly.

Error: Could not find stored procedure 'dbo.apg_sp_GetThreadList'

This means stored procedures are in a different schema than the prefix setting. Either move the procedures to the dbo schema using ALTER SCHEMA dbo TRANSFER, or update the prefix to match the current procedure schema.

Error: The specified schema name 'custom' either does not exist or you do not have permission to use it

The app pool identity doesn't have permission to access the specified schema. Grant schema access explicitly:

GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE
ON SCHEMA::custom
TO [IIS AppPool\YourAppPoolName];

DBOwnerPrefix in APG vNext Upgrade Scripts

When running APG vNext database upgrade scripts manually, the scripts reference tables with the dbo. prefix by default. If your installation uses a custom schema prefix, you must replace all occurrences of dbo. in the upgrade scripts with your custom prefix before running them, otherwise the scripts will fail or create new objects in the wrong schema.

The APG vNext team provides a parameterised version of upgrade scripts for enterprise customers that accepts the schema prefix as a SQL variable, eliminating the need for manual search-and-replace. Request the parameterised scripts from the support team if you are running a non-dbo schema configuration and need to apply an upgrade. Always run upgrade scripts in a transaction and verify the row counts match expected values before committing, regardless of which schema prefix you are using.

Related Resources


Looking for more help? Browse the support forum or check the Knowledge Base.