CreateTable - Json

Using the latest ServiceStack.Ormlite.SqlServer 5.1.1 from myget, I’m getting the error message

Cannot find data type json 

When attempting run db.CreateTableIfNotExists();
The class that I’m trying create has the following property

[CustomField("json")]
public StandardImportModel StandardInvoiceImport { get; set; }

This has worked fine in the past. Do you have any idea what might be causing the issue?

You can either enable a debug logger or register a BeforeExecFilter to print out the generated SQL:

OrmLiteConfig.BeforeExecFilter = dbCmd => Console.WriteLine(dbCmd.GetDebugString());

Then run the generated SQL in SQL Server to see the Error Response from SQL Server directly. But the error message says the DB you’re trying to run it on doesn’t have the json data type.

This is the error message,

Column, parameter, or variable #7: Cannot find data type json.

the statement for creating the column is

"StandardInvoiceImport" json NULL,

The library use to create the column with the datatype varchar(max)

This is what you’ve told OrmLite to change the data type to, which SQL Server says it doesn’t support.

Ok must of been an update on sqlserver on my machine which I wasn’t aware of as I’m sure this worked last week.

What is the correct way to tell sqlserver to create json blob column when using db.CreateTableIfNotExists?

Look at what the SQL Server column definition is for your SQL Server version and use that. There’s no SQL Standard JSON data type nor is it a data type OrmLite supports.