Trying to generate an output file in Codesmith Generator (csg).
I am using ADOXSchemaProvider to access a sql database. Am getting this error on a trivial table (1 varchar(50) field)
The syntax of the message seems to indicate the problem is rooted in CSG trying to access properties in a list/collection. Some of the other SO questions (unrealted to CSG )have suggested using reserved words could be the problem, so I am using a jumble of letters. Not the issue.
I have uninstalled / reinstalled.
Target table script is this
CREATE TABLE [dbo].[tblWitsEnd](
--[Id] [int] IDENTITY(1,1) NOT NULL,
asdf varchar(255) null
) ON [PRIMARY]
GO
Error call stack is this
Error: Item cannot be found in the collection corresponding to the requested name or ordinal.
Stack Trace:
at ADOX.Properties.get_Item(Object Item)
at SchemaExplorer.ADOXSchemaProvider.GetTableColumns(String connectionString, TableSchema table)
at SchemaExplorer.TableSchema.#o4c()
at SchemaExplorer.TableSchema.get_Columns()
at _CodeSmith.StartingBlocks30_cst.__RenderMethod1(TextWriter writer, Control control) in G:\csgtemplate.cst:line 113
at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
at CodeSmith.Engine.CodeTemplate.RenderToString()
at CodeSmith.Engine.Remoting.TemplateSession.#9Hb()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
and line 113 of my template is the first line of this code paragraph
<% for i = 0 to SourceTable.Columns.Count - 1 step 1 %>
<%= GetSetFieldSnippet(SourceTable.Columns(i) ) %>
<% next %>
Also, I did investigate whether possibly the ADOX provider uses 1 as a base for the columns index.
Problem persists if i do either of these.
<%= SourceTable.Columns.Clear %>
<%= SourceTable.Columns.Item(0) %>