{"record":{"id":"569d707e0ea8de79","repo":"EllanJiang/GameFramework","slug":"you-must-set-data-provider-helper-first-datatablemanager","errorCode":null,"errorMessage":"You must set data provider helper first.","messagePattern":"You must set data provider helper first\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/DataTable/DataTableManager.cs","lineNumber":331,"sourceCode":"            return CreateDataTable(dataRowType, string.Empty);\n        }\n\n        /// <summary>\n        /// 创建数据表。\n        /// </summary>\n        /// <typeparam name=\"T\">数据表行的类型。</typeparam>\n        /// <param name=\"name\">数据表名称。</param>\n        /// <returns>要创建的数据表。</returns>\n        public IDataTable<T> CreateDataTable<T>(string name) where T : class, IDataRow, new()\n        {\n            if (m_ResourceManager == null)\n            {\n                throw new GameFrameworkException(\"You must set resource manager first.\");\n            }\n\n            if (m_DataProviderHelper == null)\n            {\n                throw new GameFrameworkException(\"You must set data provider helper first.\");\n            }\n\n            TypeNamePair typeNamePair = new TypeNamePair(typeof(T), name);\n            if (HasDataTable<T>(name))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Already exist data table '{0}'.\", typeNamePair));\n            }\n\n            DataTable<T> dataTable = new DataTable<T>(name);\n            dataTable.SetResourceManager(m_ResourceManager);\n            dataTable.SetDataProviderHelper(m_DataProviderHelper);\n            m_DataTables.Add(typeNamePair, dataTable);\n            return dataTable;\n        }\n\n        /// <summary>\n        /// 创建数据表。\n        /// </summary>","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/DataTable/DataTableManager.cs#L313-L349","documentation":"DataTableManager.CreateDataTable<T> requires a data provider helper (IDataProviderHelper) to have been injected via SetDataProviderHelper before any table can be created. The helper supplies the table with the raw data bytes when it loads, so without it the manager cannot construct a functional DataTable<T> and throws GameFrameworkException immediately.","triggerScenarios":"Calling CreateDataTable<T>(name) or CreateDataTable<T>() when SetDataProviderHelper has never been called on the DataTableManager (or was called on a different instance / before the instance was re-created after GameFramework shutdown).","commonSituations":"Forgetting to register the data provider helper in the GameFramework component initialization; creating DataTableManager manually instead of through the Unity GameFramework component that wires helpers; rebuilding the framework component at runtime without re-setting helpers.","solutions":["Call dataTableManager.SetDataProviderHelper(dataProviderHelper) before CreateDataTable.","If using the Unity GameFramework component, ensure the Data Provider Helper is assigned in the inspector so it is wired automatically on Start.","Verify you are calling CreateDataTable on the same DataTableManager instance you configured."],"exampleFix":"// before\nDataTable<FooRow> table = dataTableManager.CreateDataTable<FooRow>(\"Foo\");\n\n// after\ndataTableManager.SetDataProviderHelper(new DataProviderHelper());\nDataTable<FooRow> table = dataTableManager.CreateDataTable<FooRow>(\"Foo\");","handlingStrategy":"validation","validationCode":"if (dataTableManager.DataProviderHelper == null)\n{\n    dataTableManager.SetDataProviderHelper(new DataProviderHelper());\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var table = dataTableManager.CreateDataTable<FooRow>(\"Foo\");\n}\ncatch (GameFrameworkException ex)\n{\n    Log.Error(\"DataTable manager not initialized: {0}\", ex.Message);\n}","preventionTips":["Set both resource manager and data provider helper in a single init routine.","Prefer the Unity GameFramework component which wires helpers automatically.","Create all tables from one initialization entry point."],"tags":["datatable","initialization","missing-helper","gameframework"],"backgroundTag":"missing-dependency","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}