I am trying to add a table in Azure Synapse using EF Core 9.0, but I am getting an error:
Parse error at line 2, column 1: Incorrect syntax near EXEC.
ActionItemStatus Class:
public class ActionItemStatus
{
public int ActionItemStatusId { get; set; }
public string Name { get; set; }
public bool IsActive { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ModifiedDate { get; set; }
}
DbContext:
public class SynapseDbContext : DbContext
{
public DbSet<ActionItemStatus> ActionItemStatus { get; set; }
public SynapseDbContext(DbContextOptions<SynapseDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ActionItemStatus>(builder =>
{
builder.HasKey(p => p.ActionItemStatusId);
builder.Property(p => p.Name).HasMaxLength(100);
builder.Property(p => p.IsActive);
builder.Property(p => p.CreatedDate);
builder.Property(p => p.ModifiedDate);
});
}
}
I generated this migration using the 'Add-Migration' command
public partial class CreateTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ActionItemStatus",
columns: table => new
{
ActionItemStatusId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ActionItemStatus", x => x.ActionItemStatusId);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ActionItemStatus");
}
}
I also have this in my Startup class:
builder.Services.AddDbContext<SynapseDbContext>(options =>
{
var connectionString = configuration.GetConnectionString("AzureSynapseConnectionString");
options.UseAzureSynapse(connectionString);
});
