EllanJiang/GameFramework · error · GameFrameworkException

Already exist data table

Error message

Already exist data table '{0}'.

What it means

CreateDataTable throws this when a table with the same type+name key (TypeNamePair) already exists in the manager's dictionary. DataTable keys are (row type, name) pairs, so duplicate registration of the same generic type and name is rejected to avoid overwriting an existing table.

Solutions

  1. Check HasDataTable<T>(name) before creating, or destroy the existing table with DestroyDataTable<T>(name) first.
  2. Use a unique table name for each table of the same row type.
  3. Restructure initialization so table creation runs only once (guard with a bool or lifecycle hook).

Example fix

// before
DataTable<FooRow> table = dataTableManager.CreateDataTable<FooRow>("Foo");

// after
if (!dataTableManager.HasDataTable<FooRow>("Foo"))
{
    DataTable<FooRow> table = dataTableManager.CreateDataTable<FooRow>("Foo");
}
Defensive patterns

Strategy: validation

Validate before calling

if (dataTableManager.HasDataTable<FooRow>("Foo"))
{
    return dataTableManager.GetDataTable<FooRow>("Foo");
}

Try / catch

try
{
    table = dataTableManager.CreateDataTable<FooRow>("Foo");
}
catch (GameFrameworkException ex) when (ex.Message.StartsWith("Already exist data table"))
{
    table = dataTableManager.GetDataTable<FooRow>("Foo");
}

Prevention

When it happens

Trigger: Calling CreateDataTable<T>(name) twice with the same T and name without destroying the first table; the generic CreateDataTable<T>() overload is also affected since it uses the type name plus an empty-name key.

Common situations: Re-initialization code paths that create tables each time a scene loads; hot-reload or domain-reload scripts re-running creation; copy-pasted creation code with the same table name for one row type.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/8c7790c884f885bd. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.cs:337

        /// <typeparam name="T">数据表行的类型。</typeparam>
        /// <param name="name">数据表名称。</param>
        /// <returns>要创建的数据表。</returns>
        public IDataTable<T> CreateDataTable<T>(string name) where T : class, IDataRow, new()
        {
            if (m_ResourceManager == null)
            {
                throw new GameFrameworkException("You must set resource manager first.");
            }

            if (m_DataProviderHelper == null)
            {
                throw new GameFrameworkException("You must set data provider helper first.");
            }

            TypeNamePair typeNamePair = new TypeNamePair(typeof(T), name);
            if (HasDataTable<T>(name))
            {
                throw new GameFrameworkException(Utility.Text.Format("Already exist data table '{0}'.", typeNamePair));
            }

            DataTable<T> dataTable = new DataTable<T>(name);
            dataTable.SetResourceManager(m_ResourceManager);
            dataTable.SetDataProviderHelper(m_DataProviderHelper);
            m_DataTables.Add(typeNamePair, dataTable);
            return dataTable;
        }

        /// <summary>
        /// 创建数据表。
        /// </summary>
        /// <param name="dataRowType">数据表行的类型。</param>
        /// <param name="name">数据表名称。</param>
        /// <returns>要创建的数据表。</returns>
        public DataTableBase CreateDataTable(Type dataRowType, string name)
        {
            if (m_ResourceManager == null)

View on GitHub (pinned to d0c010b051)