PK WthppCreateDemoSchema.sqlCREATE SCHEMA `bug_repro` DEFAULT CHARACTER SET utf8mb4 ; CREATE TABLE `bug_repro`.`sample_table` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `time_created` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), `time_updated` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), PRIMARY KEY (`id`)); PK cW!A[ Program.csglobal using Microsoft.EntityFrameworkCore; namespace WSY.MySQL.BugRepro; internal class Program { private const string ConnectionString = "Server=mysql.docker.home.wangshiyao.com;Database=bug_repro;Uid=root;Pwd=kudr75;"; static void Main(string[] args) { Console.WriteLine("Hello, World!"); var dbContextOptions = MySQLDbContextOptionsExtensions.UseMySQL(new(), ConnectionString, options => { }).Options; Console.WriteLine("Using ConnectionString: " + ConnectionString); using SampleDbContext dbContext = new(dbContextOptions); SampleTable data = new() { Name = "Sample1" }; dbContext.SampleTableDatas.Add(data); dbContext.SaveChanges(); Console.WriteLine("Data saved!"); data.Name = "Changed!"; // Will fail here dbContext.SaveChanges(); Console.WriteLine("Data updated!"); } } PK ,W-؏SampleDbContext.csnamespace WSY.MySQL.BugRepro; public class SampleDbContext : DbContext { public DbSet SampleTableDatas { get; set; } public SampleDbContext(DbContextOptions options) : base(options) { } } PK /WggSampleTable.csusing System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace WSY.MySQL.BugRepro; [Table("sample_table")] public record SampleTable { /// ID [Key] [Column("id")] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; init; } [Column("name")] public required string Name { get; set; } /// Time when this data is created [Column("time_created", TypeName = "TIMESTAMP(6)")] [DatabaseGenerated(DatabaseGeneratedOption.Computed)] public DateTime TimeCreated { get; init; } /// Time when this data is updated [Column("time_updated", TypeName = "TIMESTAMP(6)")] [DatabaseGenerated(DatabaseGeneratedOption.Computed)] public DateTime TimeUpdated { get; init; } } PK HW&9fWSY.MySQL.BugRepro.csproj Exe net8.0 enable enable 12 PK P Wh?ttWSY.MySQL.BugRepro.sln Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34322.80 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WSY.MySQL.BugRepro", "WSY.MySQL.BugRepro.csproj", "{1CBBE6DB-3D18-4E27-9130-BDA1FD2D6823}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1CBBE6DB-3D18-4E27-9130-BDA1FD2D6823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1CBBE6DB-3D18-4E27-9130-BDA1FD2D6823}.Debug|Any CPU.Build.0 = Debug|Any CPU {1CBBE6DB-3D18-4E27-9130-BDA1FD2D6823}.Release|Any CPU.ActiveCfg = Release|Any CPU {1CBBE6DB-3D18-4E27-9130-BDA1FD2D6823}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0FB01CAB-4659-4535-B501-772EAA8E1C39} EndGlobalSection EndGlobal PK? Wthpp$ CreateDemoSchema.sql /PK? cW!A[ $ Program.cs yl/PK? ,W-؏$ uSampleDbContext.cs Z/PK? /Wgg$ SampleTable.cs ~{/PK? HW&9f$ ' WSY.MySQL.BugRepro.csproj =//PK? P Wh?tt$ , WSY.MySQL.BugRepro.sln >~/PKY