I'm using Web Deploy to publish my website to a Azure Web Application with a SQL Database. I'm testing with MSSQL 2016 on my development machine. I'm using the code first model. I created a model to store security questions.
SecurityQuestion Model:
public class SecurityQuestion { public int Id { get; set; } [Column(TypeName = "NVARCHAR(250)")] public string Description { get; set; } [Column(TypeName = "NVARCHAR(250)")] public string NormalizeDescription { get; set; } [Column(TypeName = "NVARCHAR(450)")] [ForeignKey("IdentityCreated")] public string CreatedIdentityId { get; set; } public DateTime Created { get; set; } [Column(TypeName = "NVARCHAR(450)")] [ForeignKey("IdentityDisabled")] public string DisabledIdentityId { get; set; } public DateTime? Disabled { get; set; } public ApplicationUser IdentityCreated { get; set; } public ApplicationUser IdentityDisabled { get; set; } }
I wanted to be able to only add a Description and then have a trigger on the back end set the NormalizeDescription to the UPPERCASE version of the description after insert.
I created a migration to create the SecurityQuestion Table. Before I updated the database with the migration I added this bit of code to create a trigger after the table is created.
Trigger:
migrationBuilder.Sql("CREATE TRIGGER [dbo].[Trigger_SecurityQuestions_NormalizeDescription_AfterInsert] ON [dbo].[SecurityQuestions] AFTER INSERT AS BEGIN SET NOCOUNT ON; Update [dbo].[SecurityQuestions] Set [NormalizeDescription] = UPPER([Description]) Where [NormalizeDescription] is NULL; END");
I use the Update-Database command to push the changes to the database in development. The trigger is created just find and works properly. I publish the changes to my Azure account and the TRIGGER causes a error. The error says "Incorrect syntax near the keyword Trigger". This also has a side effect of not publishing my site correctly and the fails to displayed correctly after that.
I had to eliminate the trigger for now because I have no clue why it's not working correctly.
Any Ideas why this TRIGGER is causing this error?