Here is the script that can be used to generate a Knockout V.M. from a table
DECLARE @TableName VARCHAR(100) = 'Persons'
DECLARE @ShortTableName varchar(100) = 'person'
DECLARE @TableSchema VARCHAR(3) = 'dbo'
DECLARE @result varchar(max) = ''
SET @result = @result + CHAR(13)
SET @result = @result + 'var ' + @TableName + 'VM = function('+ @ShortTableName +'){' + CHAR(13)
set @result = @result + 'var self = this ;' + char(13)
SELECT @result = @result + CHAR(13)
+ 'self.' + ColumnName + ' = ko.observable(' + @ShortTableName + ' ? ' + @ShortTableName +'.' +ColumnName +' : '''');' + CHAR(13)
FROM
(
SELECT c.COLUMN_NAME AS ColumnName
, 'var' AS ColumnType
, c.ORDINAL_POSITION
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.TABLE_NAME = @TableName and ISNULL(@TableSchema, c.TABLE_SCHEMA) = c.TABLE_SCHEMA
) t
ORDER BY t.ORDINAL_POSITION
SET @result = @result + '}' + CHAR(13)
PRINT @result
DECLARE @TableName VARCHAR(100) = 'Persons'
DECLARE @ShortTableName varchar(100) = 'person'
DECLARE @TableSchema VARCHAR(3) = 'dbo'
DECLARE @result varchar(max) = ''
SET @result = @result + CHAR(13)
SET @result = @result + 'var ' + @TableName + 'VM = function('+ @ShortTableName +'){' + CHAR(13)
set @result = @result + 'var self = this ;' + char(13)
SELECT @result = @result + CHAR(13)
+ 'self.' + ColumnName + ' = ko.observable(' + @ShortTableName + ' ? ' + @ShortTableName +'.' +ColumnName +' : '''');' + CHAR(13)
FROM
(
SELECT c.COLUMN_NAME AS ColumnName
, 'var' AS ColumnType
, c.ORDINAL_POSITION
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.TABLE_NAME = @TableName and ISNULL(@TableSchema, c.TABLE_SCHEMA) = c.TABLE_SCHEMA
) t
ORDER BY t.ORDINAL_POSITION
SET @result = @result + '}' + CHAR(13)
PRINT @result