PrimaryKeys not being created

I am currently having a problem with the AutoMapper/OrmLite not creating primary keys.

This is the Class in question:

using ServiceStack.DataAnnotations;
using System;

namespace MTRAN.DataModel
{
[Alias(“Projects”)]
public class Project : BaseAuditFields
{
[PrimaryKey, AutoId]
public Guid ProjectId { get; set; }
[Required, StringLength(16), Unique]
public string ProjectCode { get; set; }
[Required, StringLength(100)]
public string ProjectName { get; set; }
[Ignore]
public string TranslatedInNos { get; set; }
[Ignore]
public int TotalWordCount { get; set; }
}
}

And this is the resulting database

Any clue as to why this is happening ? This issue only started last week and I don’t see any discernible changes in the code that would explain the sudden change in behavior.

Thank You,
Brian S

Please provide the entire base class so I can run it locally

public abstract class BaseAuditFields
{
    
    public DateTime CreatedDate { get; set; }
    public string CreatedBy { get; set; }
    public DateTime ModifiedDate { get; set; }
    public String ModifiedBy { get; set; }

    protected BaseAuditFields()
    {
        CreatedBy = "sys";
        CreatedDate = DateTime.Now;
        ModifiedBy = "sys";
        ModifiedDate = DateTime.Now;
    }
}

This is the SQL I’m getting which contains the Primary Key:

SQL: CREATE TABLE "Projects" 
(
  "ProjectId" CHAR(36) PRIMARY KEY, 
  "ProjectCode" VARCHAR(16) NOT NULL UNIQUE, 
  "ProjectName" VARCHAR(100) NOT NULL, 
  "CreatedDate" VARCHAR(8000) NOT NULL, 
  "CreatedBy" VARCHAR(8000) NULL, 
  "ModifiedDate" VARCHAR(8000) NOT NULL, 
  "ModifiedBy" VARCHAR(8000) NULL 
);

Can you run run it in a test and display the output:

[Test]
public void Create_Table()
{
    OrmLiteUtils.PrintSql();

    using (var db = OpenDbConnection())
    {
        db.CreateTable<Project>();
    }
}

SQL: CREATE TABLE “Projects”
(
“ProjectCode” VARCHAR(16) NOT NULL,
“ProjectName” VARCHAR(100) NOT NULL,
“CreatedDate” DATETIME NOT NULL,
“CreatedBy” VARCHAR(8000) NULL,
“ModifiedDate” DATETIME NOT NULL,
“ModifiedBy” VARCHAR(8000) NULL
);

Something is different in your environment or you’re giving me different code to run, I’ve added it to Gistlyn:

https://gistlyn.com/?gist=f1560e113cbb19749d995b7b5066774f&collection=2cc6b5db6afd3ccb0d0149e55fdb3a6a

which also produces:

SQL: CREATE TABLE "Projects" 
(
  "ProjectId" CHAR(36) PRIMARY KEY, 
  "ProjectCode" VARCHAR(16) NOT NULL UNIQUE, 
  "ProjectName" VARCHAR(100) NOT NULL, 
  "CreatedDate" VARCHAR(8000) NOT NULL, 
  "CreatedBy" VARCHAR(8000) NULL, 
  "ModifiedDate" VARCHAR(8000) NOT NULL, 
  "ModifiedBy" VARCHAR(8000) NULL 
);