You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near.....in migration

Viewed 18

here it's my code i wanted to add default value time to all of the Dates which will be created in Database but this error comes again & again I don't figure out what is the problem as I am not a pro developer I did not see what I'm doing wrong here can anyone guide ??? as I have attached picture of the problem below so you can understand easily.

using Microsoft.EntityFrameworkCore;
using System.Configuration;

namespace ApiProject.Models
{
    public class relationshipContext : DbContext
    {


        public relationshipContext(DbContextOptions<relationshipContext> options)
            : base(options)
    {
    }

    public DbSet<detectors> detectors { get; set; } = null!;

    public DbSet<dictionary> dictionary { get; set; } = null!;
    public DbSet<tenant> tenant { get; set; } = null!;
    public DbSet<users> users { get; set; } = null!;
    public DbSet<subscription> subscription { get; set; } = null!;
    public DbSet<rules> rules { get; set; } = null!;
    public DbSet<keywords> keywords { get; set; } = null!;


    protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<tenant>(e => e.Property(o => o.tenantStartDate).HasDefaultValueSql("getdate()"));
            modelBuilder.Entity<tenant>(e => e.Property(a => a.tenantEndDate).HasDefaultValueSql("getdate()"));
            modelBuilder.Entity<subscription>(e => e.Property(b => b.subStartDate).HasDefaultValueSql("getdate()"));
            modelBuilder.Entity<subscription>(e => e.Property(c => c.subEndDate).HasDefaultValueSql("getdate()"));
        }


    }

        
}

enter image description here

0 Answers
Related