From 1717a42031fa0575d00dd2432a61046d8cdd93d2 Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 15:07:42 +0800 Subject: [PATCH 1/9] Rollback db to V1 --- .../Migrations/20250323190719_V2.Designer.cs | 548 ------------------ src/MvcDemo/Migrations/20250323190719_V2.cs | 254 -------- .../Migrations/DemoDbContextModelSnapshot.cs | 338 ++++++----- 3 files changed, 202 insertions(+), 938 deletions(-) delete mode 100644 src/MvcDemo/Migrations/20250323190719_V2.Designer.cs delete mode 100644 src/MvcDemo/Migrations/20250323190719_V2.cs diff --git a/src/MvcDemo/Migrations/20250323190719_V2.Designer.cs b/src/MvcDemo/Migrations/20250323190719_V2.Designer.cs deleted file mode 100644 index d342b94..0000000 --- a/src/MvcDemo/Migrations/20250323190719_V2.Designer.cs +++ /dev/null @@ -1,548 +0,0 @@ -// -using System; -using Demo.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Demo.Migrations -{ - [DbContext(typeof(DemoDbContext))] - [Migration("20250323190719_V2")] - partial class V2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.14"); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("TEXT"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ClaimType") - .HasColumnType("TEXT"); - - b.Property("ClaimValue") - .HasColumnType("TEXT"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("AccessFailedCount") - .HasColumnType("INTEGER"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("TEXT"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("EmailConfirmed") - .HasColumnType("INTEGER"); - - b.Property("LockoutEnabled") - .HasColumnType("INTEGER"); - - b.Property("LockoutEnd") - .HasColumnType("TEXT"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.Property("PasswordHash") - .HasColumnType("TEXT"); - - b.Property("PhoneNumber") - .HasColumnType("TEXT"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("INTEGER"); - - b.Property("SecurityStamp") - .HasColumnType("TEXT"); - - b.Property("TwoFactorEnabled") - .HasColumnType("INTEGER"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ClaimType") - .HasColumnType("TEXT"); - - b.Property("ClaimValue") - .HasColumnType("TEXT"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("TEXT"); - - b.Property("ProviderKey") - .HasColumnType("TEXT"); - - b.Property("ProviderDisplayName") - .HasColumnType("TEXT"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("TEXT"); - - b.Property("RoleId") - .HasColumnType("TEXT"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("TEXT"); - - b.Property("LoginProvider") - .HasColumnType("TEXT"); - - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasColumnType("TEXT"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedEventEntity", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); - - b.Property("CreateTime") - .HasColumnType("INTEGER"); - - b.Property("Event") - .HasColumnType("TEXT"); - - b.Property("EventKey") - .HasColumnType("TEXT"); - - b.Property("FromUserName") - .HasColumnType("TEXT"); - - b.Property("Latitude") - .HasColumnType("TEXT"); - - b.Property("Longitude") - .HasColumnType("TEXT"); - - b.Property("MsgType") - .HasColumnType("TEXT"); - - b.Property("Precision") - .HasColumnType("TEXT"); - - b.Property("Ticket") - .HasColumnType("TEXT"); - - b.Property("ToUserName") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("WeixinReceivedEvents"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedMessageEntity", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); - - b.Property("Content") - .HasColumnType("TEXT"); - - b.Property("CreateTime") - .HasColumnType("INTEGER"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Format") - .HasColumnType("TEXT"); - - b.Property("FromUserName") - .HasColumnType("TEXT"); - - b.Property("Label") - .HasColumnType("TEXT"); - - b.Property("Latitude") - .HasColumnType("TEXT"); - - b.Property("Longitude") - .HasColumnType("TEXT"); - - b.Property("MediaId") - .HasColumnType("TEXT"); - - b.Property("MsgId") - .HasColumnType("INTEGER"); - - b.Property("MsgType") - .HasColumnType("TEXT"); - - b.Property("PicUrl") - .HasColumnType("TEXT"); - - b.Property("Recognition") - .HasColumnType("TEXT"); - - b.Property("Scale") - .HasColumnType("TEXT"); - - b.Property("ThumbMediaId") - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("ToUserName") - .HasColumnType("TEXT"); - - b.Property("Url") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("WeixinReceivedMessages"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinResponseMessageEntity", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); - - b.Property("Content") - .HasColumnType("TEXT"); - - b.Property("CreateTime") - .HasColumnType("INTEGER"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Format") - .HasColumnType("TEXT"); - - b.Property("FromUserName") - .HasColumnType("TEXT"); - - b.Property("Label") - .HasColumnType("TEXT"); - - b.Property("Latitude") - .HasColumnType("TEXT"); - - b.Property("Longitude") - .HasColumnType("TEXT"); - - b.Property("MediaId") - .HasColumnType("TEXT"); - - b.Property("MsgId") - .HasColumnType("TEXT"); - - b.Property("MsgType") - .HasColumnType("TEXT"); - - b.Property("PicUrl") - .HasColumnType("TEXT"); - - b.Property("RequestId") - .HasColumnType("TEXT"); - - b.Property("Scale") - .HasColumnType("TEXT"); - - b.Property("ThumbMediaId") - .HasColumnType("TEXT"); - - b.Property("Title") - .HasColumnType("TEXT"); - - b.Property("ToUserName") - .HasColumnType("TEXT"); - - b.Property("Url") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("WeixinResponseMessages"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSendMessageEntity", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); - - b.Property("Content") - .HasColumnType("TEXT"); - - b.Property("CreateTime") - .HasColumnType("INTEGER"); - - b.Property("FromUserName") - .HasColumnType("TEXT"); - - b.Property("LastRetCode") - .HasColumnType("INTEGER"); - - b.Property("LastRetMsg") - .HasColumnType("TEXT"); - - b.Property("LastTried") - .HasColumnType("TEXT"); - - b.Property("RetryTimes") - .HasColumnType("INTEGER"); - - b.Property("ScheduleTime") - .HasColumnType("TEXT"); - - b.Property("ToUserName") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("WeixinSendMessages"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSubscriberEntity", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("City") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); - - b.Property("Country") - .HasColumnType("TEXT"); - - b.Property("HeadImgUrl") - .HasColumnType("TEXT"); - - b.Property("Language") - .HasColumnType("TEXT"); - - b.Property("MentorId") - .HasColumnType("TEXT"); - - b.Property("Nickname") - .HasColumnType("TEXT"); - - b.Property("OpenId") - .HasMaxLength(32) - .HasColumnType("TEXT"); - - b.Property("Province") - .HasColumnType("TEXT"); - - b.Property("Remark") - .HasColumnType("TEXT"); - - b.Property("SecurityStamp") - .HasColumnType("TEXT"); - - b.Property("Sex") - .HasColumnType("INTEGER"); - - b.Property("SubscribeTime") - .HasColumnType("INTEGER"); - - b.Property("Subscribed") - .HasColumnType("INTEGER"); - - b.Property("UnionId") - .HasMaxLength(32) - .HasColumnType("TEXT"); - - b.Property("UnsubscribeTime") - .HasColumnType("INTEGER"); - - b.Property("UserId") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("WeixinSubscribers"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MvcDemo/Migrations/20250323190719_V2.cs b/src/MvcDemo/Migrations/20250323190719_V2.cs deleted file mode 100644 index ee8e147..0000000 --- a/src/MvcDemo/Migrations/20250323190719_V2.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Demo.Migrations -{ - /// - public partial class V2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AuditEntires"); - - migrationBuilder.DropPrimaryKey( - name: "PK_WeixinSubscribers", - table: "WeixinSubscribers"); - - migrationBuilder.DropColumn( - name: "AppId", - table: "WeixinSubscribers"); - - migrationBuilder.DropColumn( - name: "CreateUnixTime", - table: "WeixinSubscribers"); - - migrationBuilder.DropColumn( - name: "RowVersion", - table: "WeixinSubscribers"); - - migrationBuilder.RenameColumn( - name: "Gender", - table: "WeixinSubscribers", - newName: "Sex"); - - migrationBuilder.RenameColumn( - name: "NickName", - table: "WeixinSubscribers", - newName: "Nickname"); - - migrationBuilder.RenameColumn( - name: "AvatorImageUrl", - table: "WeixinSubscribers", - newName: "HeadImgUrl"); - - migrationBuilder.RenameColumn( - name: "SubscribedTime", - table: "WeixinSubscribers", - newName: "SubscribeTime"); - - migrationBuilder.RenameColumn( - name: "Unsubscribed", - table: "WeixinSubscribers", - newName: "Subscribed"); - - migrationBuilder.RenameColumn( - name: "UnsubscribedTime", - table: "WeixinSubscribers", - newName: "UnsubscribeTime"); - - migrationBuilder.AddColumn( - name: "Id", - table: "WeixinSubscribers", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "SecurityStamp", - table: "WeixinSubscribers", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "ConcurrencyStamp", - table: "WeixinSubscribers", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreateTime", - table: "WeixinReceivedMessages", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "ConcurrencyStamp", - table: "WeixinReceivedMessages", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "CreateTime", - table: "WeixinReceivedEvents", - type: "INTEGER", - nullable: true); - - migrationBuilder.AddColumn( - name: "ConcurrencyStamp", - table: "WeixinReceivedEvents", - type: "TEXT", - nullable: true); - - migrationBuilder.AddPrimaryKey( - name: "PK_WeixinSubscribers", - table: "WeixinSubscribers", - column: "Id"); - - migrationBuilder.CreateTable( - name: "WeixinResponseMessages", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - FromUserName = table.Column(type: "TEXT", nullable: true), - ToUserName = table.Column(type: "TEXT", nullable: true), - CreateTime = table.Column(type: "INTEGER", nullable: true), - MsgType = table.Column(type: "TEXT", nullable: true), - MsgId = table.Column(type: "TEXT", nullable: true), - Content = table.Column(type: "TEXT", nullable: true), - PicUrl = table.Column(type: "TEXT", nullable: true), - MediaId = table.Column(type: "TEXT", nullable: true), - Format = table.Column(type: "TEXT", nullable: true), - ThumbMediaId = table.Column(type: "TEXT", nullable: true), - Longitude = table.Column(type: "TEXT", nullable: false), - Latitude = table.Column(type: "TEXT", nullable: false), - Scale = table.Column(type: "TEXT", nullable: false), - Label = table.Column(type: "TEXT", nullable: true), - Title = table.Column(type: "TEXT", nullable: true), - Url = table.Column(type: "TEXT", nullable: true), - Description = table.Column(type: "TEXT", nullable: true), - RequestId = table.Column(type: "TEXT", nullable: true), - ConcurrencyStamp = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_WeixinResponseMessages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "WeixinSendMessages", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - FromUserName = table.Column(type: "TEXT", nullable: true), - ToUserName = table.Column(type: "TEXT", nullable: true), - CreateTime = table.Column(type: "INTEGER", nullable: true), - Content = table.Column(type: "TEXT", nullable: true), - ScheduleTime = table.Column(type: "TEXT", nullable: true), - LastRetCode = table.Column(type: "INTEGER", nullable: true), - LastRetMsg = table.Column(type: "TEXT", nullable: true), - RetryTimes = table.Column(type: "INTEGER", nullable: false), - LastTried = table.Column(type: "TEXT", nullable: true), - ConcurrencyStamp = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_WeixinSendMessages", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "WeixinResponseMessages"); - - migrationBuilder.DropTable( - name: "WeixinSendMessages"); - - migrationBuilder.DropPrimaryKey( - name: "PK_WeixinSubscribers", - table: "WeixinSubscribers"); - - migrationBuilder.RenameColumn( - name: "Sex", - table: "WeixinSubscribers", - newName: "Gender"); - - migrationBuilder.RenameColumn( - name: "SubscribeTime", - table: "WeixinSubscribers", - newName: "SubscribedTime"); - - migrationBuilder.RenameColumn( - name: "UnsubscribeTime", - table: "WeixinSubscribers", - newName: "UnsubscribedTime"); - - migrationBuilder.RenameColumn( - name: "Subscribed", - table: "WeixinSubscribers", - newName: "Unsubscribed"); - - migrationBuilder.DropColumn( - name: "SecurityStamp", - table: "WeixinSubscribers"); - - migrationBuilder.RenameColumn( - name: "HeadImgUrl", - table: "WeixinSubscribers", - newName: "AvatorImageUrl"); - - migrationBuilder.AddColumn( - name: "AppId", - table: "WeixinSubscribers", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "RowVersion", - table: "WeixinSubscribers", - type: "BLOB", - rowVersion: true, - nullable: true); - - migrationBuilder.AddColumn( - name: "CreateUnixTime", - table: "WeixinReceivedMessages", - type: "INTEGER", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "CreateUnixTime", - table: "WeixinReceivedEvents", - type: "INTEGER", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddPrimaryKey( - name: "PK_WeixinSubscribers", - table: "WeixinSubscribers", - column: "OpenId"); - - migrationBuilder.CreateTable( - name: "AuditEntires", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false), - CreatedTime = table.Column(type: "TEXT", nullable: false), - KeyValue = table.Column(type: "TEXT", nullable: true), - NewValue = table.Column(type: "TEXT", nullable: true), - OldValue = table.Column(type: "TEXT", nullable: true), - TableName = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AuditEntires", x => x.Id); - }); - } - } -} diff --git a/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs b/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs index d6d36bf..30bcce9 100644 --- a/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs +++ b/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ partial class DemoDbContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.14"); + modelBuilder.HasAnnotation("ProductVersion", "6.0.3"); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { @@ -209,141 +209,174 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserTokens", (string)null); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedEventEntity", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.AuditEntry", b => { b.Property("Id") .HasColumnType("TEXT"); - b.Property("ConcurrencyStamp") + b.Property("CreatedTime") .HasColumnType("TEXT"); - b.Property("CreateTime") - .HasColumnType("INTEGER"); - - b.Property("Event") + b.Property("KeyValue") .HasColumnType("TEXT"); - b.Property("EventKey") + b.Property("NewValue") .HasColumnType("TEXT"); - b.Property("FromUserName") + b.Property("OldValue") .HasColumnType("TEXT"); - b.Property("Latitude") + b.Property("TableName") .HasColumnType("TEXT"); - b.Property("Longitude") + b.HasKey("Id"); + + b.ToTable("AuditEntires", (string)null); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry", b => + { + b.Property("Id") .HasColumnType("TEXT"); - b.Property("MsgType") + b.Property("CreateUnixTime") + .HasColumnType("INTEGER"); + + b.Property("Event") + .IsRequired() .HasColumnType("TEXT"); - b.Property("Precision") + b.Property("FromUserName") + .IsRequired() + .HasMaxLength(32) .HasColumnType("TEXT"); - b.Property("Ticket") + b.Property("MsgType") + .IsRequired() .HasColumnType("TEXT"); b.Property("ToUserName") + .IsRequired() + .HasMaxLength(32) .HasColumnType("TEXT"); b.HasKey("Id"); - b.ToTable("WeixinReceivedEvents"); + b.ToTable("WeixinReceivedEvents", (string)null); + + b.HasDiscriminator("Event").HasValue("EventReceivedEntry"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedMessageEntity", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry", b => { b.Property("Id") .HasColumnType("TEXT"); - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); + b.Property("CreateUnixTime") + .HasColumnType("INTEGER"); - b.Property("Content") + b.Property("FromUserName") + .IsRequired() + .HasMaxLength(32) .HasColumnType("TEXT"); - b.Property("CreateTime") + b.Property("MsgId") .HasColumnType("INTEGER"); - b.Property("Description") + b.Property("MsgType") + .IsRequired() .HasColumnType("TEXT"); - b.Property("Format") + b.Property("ToUserName") + .IsRequired() + .HasMaxLength(32) .HasColumnType("TEXT"); - b.Property("FromUserName") + b.HasKey("Id"); + + b.ToTable("WeixinReceivedMessages", (string)null); + + b.HasDiscriminator("MsgType").HasValue("MessageReceivedEntry"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.Subscriber", b => + { + b.Property("OpenId") + .HasMaxLength(32) .HasColumnType("TEXT"); - b.Property("Label") + b.Property("AppId") .HasColumnType("TEXT"); - b.Property("Latitude") + b.Property("AvatorImageUrl") .HasColumnType("TEXT"); - b.Property("Longitude") + b.Property("City") .HasColumnType("TEXT"); - b.Property("MediaId") + b.Property("Country") .HasColumnType("TEXT"); - b.Property("MsgId") + b.Property("Gender") .HasColumnType("INTEGER"); - b.Property("MsgType") + b.Property("Language") .HasColumnType("TEXT"); - b.Property("PicUrl") + b.Property("MentorId") .HasColumnType("TEXT"); - b.Property("Recognition") + b.Property("Nickname") .HasColumnType("TEXT"); - b.Property("Scale") + b.Property("Province") .HasColumnType("TEXT"); - b.Property("ThumbMediaId") + b.Property("Remark") .HasColumnType("TEXT"); - b.Property("Title") - .HasColumnType("TEXT"); + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("BLOB"); - b.Property("ToUserName") + b.Property("SubscribedTime") .HasColumnType("TEXT"); - b.Property("Url") + b.Property("UnionId") + .HasMaxLength(32) .HasColumnType("TEXT"); - b.HasKey("Id"); - - b.ToTable("WeixinReceivedMessages"); - }); + b.Property("Unsubscribed") + .IsRequired() + .HasColumnType("INTEGER"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinResponseMessageEntity", b => - { - b.Property("Id") + b.Property("UnsubscribedTime") .HasColumnType("TEXT"); - b.Property("ConcurrencyStamp") + b.Property("UserId") .HasColumnType("TEXT"); - b.Property("Content") - .HasColumnType("TEXT"); + b.HasKey("OpenId"); - b.Property("CreateTime") - .HasColumnType("INTEGER"); + b.ToTable("WeixinSubscribers", (string)null); + }); - b.Property("Description") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ClickMenuEventReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - b.Property("Format") - .HasColumnType("TEXT"); + b.Property("EventKey") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("EventKey"); - b.Property("FromUserName") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("CLICK"); + }); - b.Property("Label") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LocationEventReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); b.Property("Latitude") .HasColumnType("TEXT"); @@ -351,142 +384,175 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Longitude") .HasColumnType("TEXT"); - b.Property("MediaId") + b.Property("Precision") .HasColumnType("TEXT"); - b.Property("MsgId") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("LOCATION"); + }); - b.Property("MsgType") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.QrscanEventReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - b.Property("PicUrl") - .HasColumnType("TEXT"); + b.Property("EventKey") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("EventKey"); - b.Property("RequestId") - .HasColumnType("TEXT"); + b.Property("Ticket") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("Ticket"); - b.Property("Scale") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("SCAN"); + }); - b.Property("ThumbMediaId") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.SubscribeEventReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - b.Property("Title") - .HasColumnType("TEXT"); + b.Property("EventKey") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("EventKey"); - b.Property("ToUserName") - .HasColumnType("TEXT"); + b.Property("Ticket") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("Ticket"); - b.Property("Url") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("subscribe"); + }); - b.HasKey("Id"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.UnsubscribeEventReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - b.ToTable("WeixinResponseMessages"); + b.HasDiscriminator().HasValue("unsubscribe"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSendMessageEntity", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ViewMenuEventReceivedEntry", b => { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("ConcurrencyStamp") - .HasColumnType("TEXT"); + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - b.Property("Content") - .HasColumnType("TEXT"); + b.Property("EventKey") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("EventKey"); - b.Property("CreateTime") - .HasColumnType("INTEGER"); + b.HasDiscriminator().HasValue("VIEW"); + }); - b.Property("FromUserName") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ImageMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("LastRetCode") - .HasColumnType("INTEGER"); + b.Property("MediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("MediaId"); - b.Property("LastRetMsg") + b.Property("PicUrl") .HasColumnType("TEXT"); - b.Property("LastTried") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("image"); + }); - b.Property("RetryTimes") - .HasColumnType("INTEGER"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LinkMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("ScheduleTime") + b.Property("Description") .HasColumnType("TEXT"); - b.Property("ToUserName") + b.Property("Title") .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property("Url") + .HasColumnType("TEXT"); - b.ToTable("WeixinSendMessages"); + b.HasDiscriminator().HasValue("link"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSubscriberEntity", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LocationMessageReceivedEntry", b => { - b.Property("Id") - .HasColumnType("TEXT"); + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("City") + b.Property("Label") .HasColumnType("TEXT"); - b.Property("ConcurrencyStamp") + b.Property("Latitude") .HasColumnType("TEXT"); - b.Property("Country") + b.Property("Longitude") .HasColumnType("TEXT"); - b.Property("HeadImgUrl") + b.Property("Scale") .HasColumnType("TEXT"); - b.Property("Language") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("location"); + }); - b.Property("MentorId") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ShortVideoMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("Nickname") - .HasColumnType("TEXT"); + b.Property("MediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("MediaId"); - b.Property("OpenId") - .HasMaxLength(32) - .HasColumnType("TEXT"); + b.Property("ThumbMediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("ThumbMediaId"); - b.Property("Province") - .HasColumnType("TEXT"); + b.HasDiscriminator().HasValue("shortvideo"); + }); - b.Property("Remark") - .HasColumnType("TEXT"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.TextMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("SecurityStamp") + b.Property("Content") .HasColumnType("TEXT"); - b.Property("Sex") - .HasColumnType("INTEGER"); + b.HasDiscriminator().HasValue("text"); + }); - b.Property("SubscribeTime") - .HasColumnType("INTEGER"); + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.VideoMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - b.Property("Subscribed") - .HasColumnType("INTEGER"); + b.Property("MediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("MediaId"); - b.Property("UnionId") - .HasMaxLength(32) - .HasColumnType("TEXT"); + b.Property("ThumbMediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("ThumbMediaId"); - b.Property("UnsubscribeTime") - .HasColumnType("INTEGER"); + b.HasDiscriminator().HasValue("video"); + }); - b.Property("UserId") + modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.VoiceMessageReceivedEntry", b => + { + b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + + b.Property("Format") .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property("MediaId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("TEXT") + .HasColumnName("MediaId"); + + b.Property("Recognition") + .HasColumnType("TEXT"); - b.ToTable("WeixinSubscribers"); + b.HasDiscriminator().HasValue("voice"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => From 621a375adacf6d8882a55340cd6b1789bbe687ff Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 15:08:51 +0800 Subject: [PATCH 2/9] Update db to V3 --- .../Migrations/20250325070817_V3.Designer.cs | 548 ++++++++++++++++++ src/MvcDemo/Migrations/20250325070817_V3.cs | 451 ++++++++++++++ .../Migrations/DemoDbContextModelSnapshot.cs | 338 +++++------ 3 files changed, 1135 insertions(+), 202 deletions(-) create mode 100644 src/MvcDemo/Migrations/20250325070817_V3.Designer.cs create mode 100644 src/MvcDemo/Migrations/20250325070817_V3.cs diff --git a/src/MvcDemo/Migrations/20250325070817_V3.Designer.cs b/src/MvcDemo/Migrations/20250325070817_V3.Designer.cs new file mode 100644 index 0000000..c1b5614 --- /dev/null +++ b/src/MvcDemo/Migrations/20250325070817_V3.Designer.cs @@ -0,0 +1,548 @@ +// +using System; +using Demo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Demo.Migrations +{ + [DbContext(typeof(DemoDbContext))] + [Migration("20250325070817_V3")] + partial class V3 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.14"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedEventEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("INTEGER"); + + b.Property("Event") + .HasColumnType("TEXT"); + + b.Property("EventKey") + .HasColumnType("TEXT"); + + b.Property("FromUserName") + .HasColumnType("TEXT"); + + b.Property("Latitude") + .HasColumnType("TEXT"); + + b.Property("Longitude") + .HasColumnType("TEXT"); + + b.Property("MsgType") + .HasColumnType("TEXT"); + + b.Property("Precision") + .HasColumnType("TEXT"); + + b.Property("Ticket") + .HasColumnType("TEXT"); + + b.Property("ToUserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WeixinReceivedEvents"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedMessageEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); + + b.Property("Content") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("TEXT"); + + b.Property("FromUserName") + .HasColumnType("TEXT"); + + b.Property("Label") + .HasColumnType("TEXT"); + + b.Property("Latitude") + .HasColumnType("TEXT"); + + b.Property("Longitude") + .HasColumnType("TEXT"); + + b.Property("MediaId") + .HasColumnType("TEXT"); + + b.Property("MsgId") + .HasColumnType("INTEGER"); + + b.Property("MsgType") + .HasColumnType("TEXT"); + + b.Property("PicUrl") + .HasColumnType("TEXT"); + + b.Property("Recognition") + .HasColumnType("TEXT"); + + b.Property("Scale") + .HasColumnType("TEXT"); + + b.Property("ThumbMediaId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("ToUserName") + .HasColumnType("TEXT"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WeixinReceivedMessages"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinResponseMessageEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); + + b.Property("Content") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("TEXT"); + + b.Property("FromUserName") + .HasColumnType("TEXT"); + + b.Property("Label") + .HasColumnType("TEXT"); + + b.Property("Latitude") + .HasColumnType("TEXT"); + + b.Property("Longitude") + .HasColumnType("TEXT"); + + b.Property("MediaId") + .HasColumnType("TEXT"); + + b.Property("MsgId") + .HasColumnType("TEXT"); + + b.Property("MsgType") + .HasColumnType("TEXT"); + + b.Property("PicUrl") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("TEXT"); + + b.Property("Scale") + .HasColumnType("TEXT"); + + b.Property("ThumbMediaId") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("ToUserName") + .HasColumnType("TEXT"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WeixinResponseMessages"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSendMessageEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); + + b.Property("Content") + .HasColumnType("TEXT"); + + b.Property("CreateTime") + .HasColumnType("INTEGER"); + + b.Property("FromUserName") + .HasColumnType("TEXT"); + + b.Property("LastRetCode") + .HasColumnType("INTEGER"); + + b.Property("LastRetMsg") + .HasColumnType("TEXT"); + + b.Property("LastTried") + .HasColumnType("TEXT"); + + b.Property("RetryTimes") + .HasColumnType("INTEGER"); + + b.Property("ScheduleTime") + .HasColumnType("TEXT"); + + b.Property("ToUserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WeixinSendMessages"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSubscriberEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("City") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); + + b.Property("Country") + .HasColumnType("TEXT"); + + b.Property("HeadImgUrl") + .HasColumnType("TEXT"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("MentorId") + .HasColumnType("TEXT"); + + b.Property("Nickname") + .HasColumnType("TEXT"); + + b.Property("OpenId") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("Province") + .HasColumnType("TEXT"); + + b.Property("Remark") + .HasColumnType("TEXT"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("Sex") + .HasColumnType("INTEGER"); + + b.Property("SubscribeTime") + .HasColumnType("INTEGER"); + + b.Property("Subscribed") + .HasColumnType("INTEGER"); + + b.Property("UnionId") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("UnsubscribeTime") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("WeixinSubscribers"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/MvcDemo/Migrations/20250325070817_V3.cs b/src/MvcDemo/Migrations/20250325070817_V3.cs new file mode 100644 index 0000000..83e2fc5 --- /dev/null +++ b/src/MvcDemo/Migrations/20250325070817_V3.cs @@ -0,0 +1,451 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Demo.Migrations +{ + /// + public partial class V3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AuditEntires"); + + migrationBuilder.DropPrimaryKey( + name: "PK_WeixinSubscribers", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "AppId", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "RowVersion", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "CreateUnixTime", + table: "WeixinReceivedMessages"); + + migrationBuilder.DropColumn( + name: "CreateUnixTime", + table: "WeixinReceivedEvents"); + + migrationBuilder.RenameColumn( + name: "UnsubscribedTime", + table: "WeixinSubscribers", + newName: "SecurityStamp"); + + migrationBuilder.RenameColumn( + name: "Unsubscribed", + table: "WeixinSubscribers", + newName: "Subscribed"); + + migrationBuilder.RenameColumn( + name: "SubscribedTime", + table: "WeixinSubscribers", + newName: "HeadImgUrl"); + + migrationBuilder.RenameColumn( + name: "Gender", + table: "WeixinSubscribers", + newName: "UnsubscribeTime"); + + migrationBuilder.RenameColumn( + name: "AvatorImageUrl", + table: "WeixinSubscribers", + newName: "ConcurrencyStamp"); + + migrationBuilder.AlterColumn( + name: "OpenId", + table: "WeixinSubscribers", + type: "TEXT", + maxLength: 32, + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32); + + migrationBuilder.AddColumn( + name: "Id", + table: "WeixinSubscribers", + type: "TEXT", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Sex", + table: "WeixinSubscribers", + type: "INTEGER", + nullable: true); + + migrationBuilder.AddColumn( + name: "SubscribeTime", + table: "WeixinSubscribers", + type: "INTEGER", + nullable: true); + + migrationBuilder.AlterColumn( + name: "ToUserName", + table: "WeixinReceivedMessages", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "MsgType", + table: "WeixinReceivedMessages", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "MsgId", + table: "WeixinReceivedMessages", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FromUserName", + table: "WeixinReceivedMessages", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32); + + migrationBuilder.AddColumn( + name: "ConcurrencyStamp", + table: "WeixinReceivedMessages", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreateTime", + table: "WeixinReceivedMessages", + type: "INTEGER", + nullable: true); + + migrationBuilder.AlterColumn( + name: "ToUserName", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "MsgType", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "FromUserName", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32); + + migrationBuilder.AlterColumn( + name: "Event", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT"); + + migrationBuilder.AddColumn( + name: "ConcurrencyStamp", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "CreateTime", + table: "WeixinReceivedEvents", + type: "INTEGER", + nullable: true); + + migrationBuilder.AddPrimaryKey( + name: "PK_WeixinSubscribers", + table: "WeixinSubscribers", + column: "Id"); + + migrationBuilder.CreateTable( + name: "WeixinResponseMessages", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + FromUserName = table.Column(type: "TEXT", nullable: true), + ToUserName = table.Column(type: "TEXT", nullable: true), + CreateTime = table.Column(type: "INTEGER", nullable: true), + MsgType = table.Column(type: "TEXT", nullable: true), + MsgId = table.Column(type: "TEXT", nullable: true), + Content = table.Column(type: "TEXT", nullable: true), + PicUrl = table.Column(type: "TEXT", nullable: true), + MediaId = table.Column(type: "TEXT", nullable: true), + Format = table.Column(type: "TEXT", nullable: true), + ThumbMediaId = table.Column(type: "TEXT", nullable: true), + Longitude = table.Column(type: "TEXT", nullable: false), + Latitude = table.Column(type: "TEXT", nullable: false), + Scale = table.Column(type: "TEXT", nullable: false), + Label = table.Column(type: "TEXT", nullable: true), + Title = table.Column(type: "TEXT", nullable: true), + Url = table.Column(type: "TEXT", nullable: true), + Description = table.Column(type: "TEXT", nullable: true), + RequestId = table.Column(type: "TEXT", nullable: true), + ConcurrencyStamp = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WeixinResponseMessages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WeixinSendMessages", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + FromUserName = table.Column(type: "TEXT", nullable: true), + ToUserName = table.Column(type: "TEXT", nullable: true), + CreateTime = table.Column(type: "INTEGER", nullable: true), + Content = table.Column(type: "TEXT", nullable: true), + ScheduleTime = table.Column(type: "TEXT", nullable: true), + LastRetCode = table.Column(type: "INTEGER", nullable: true), + LastRetMsg = table.Column(type: "TEXT", nullable: true), + RetryTimes = table.Column(type: "INTEGER", nullable: false), + LastTried = table.Column(type: "TEXT", nullable: true), + ConcurrencyStamp = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WeixinSendMessages", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "WeixinResponseMessages"); + + migrationBuilder.DropTable( + name: "WeixinSendMessages"); + + migrationBuilder.DropPrimaryKey( + name: "PK_WeixinSubscribers", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "Id", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "Sex", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "SubscribeTime", + table: "WeixinSubscribers"); + + migrationBuilder.DropColumn( + name: "ConcurrencyStamp", + table: "WeixinReceivedMessages"); + + migrationBuilder.DropColumn( + name: "CreateTime", + table: "WeixinReceivedMessages"); + + migrationBuilder.DropColumn( + name: "ConcurrencyStamp", + table: "WeixinReceivedEvents"); + + migrationBuilder.DropColumn( + name: "CreateTime", + table: "WeixinReceivedEvents"); + + migrationBuilder.RenameColumn( + name: "UnsubscribeTime", + table: "WeixinSubscribers", + newName: "Gender"); + + migrationBuilder.RenameColumn( + name: "Subscribed", + table: "WeixinSubscribers", + newName: "Unsubscribed"); + + migrationBuilder.RenameColumn( + name: "SecurityStamp", + table: "WeixinSubscribers", + newName: "UnsubscribedTime"); + + migrationBuilder.RenameColumn( + name: "HeadImgUrl", + table: "WeixinSubscribers", + newName: "SubscribedTime"); + + migrationBuilder.RenameColumn( + name: "ConcurrencyStamp", + table: "WeixinSubscribers", + newName: "AvatorImageUrl"); + + migrationBuilder.AlterColumn( + name: "OpenId", + table: "WeixinSubscribers", + type: "TEXT", + maxLength: 32, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 32, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "AppId", + table: "WeixinSubscribers", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "RowVersion", + table: "WeixinSubscribers", + type: "BLOB", + rowVersion: true, + nullable: true); + + migrationBuilder.AlterColumn( + name: "ToUserName", + table: "WeixinReceivedMessages", + type: "TEXT", + maxLength: 32, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MsgType", + table: "WeixinReceivedMessages", + type: "TEXT", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MsgId", + table: "WeixinReceivedMessages", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FromUserName", + table: "WeixinReceivedMessages", + type: "TEXT", + maxLength: 32, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CreateUnixTime", + table: "WeixinReceivedMessages", + type: "INTEGER", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AlterColumn( + name: "ToUserName", + table: "WeixinReceivedEvents", + type: "TEXT", + maxLength: 32, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MsgType", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FromUserName", + table: "WeixinReceivedEvents", + type: "TEXT", + maxLength: 32, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Event", + table: "WeixinReceivedEvents", + type: "TEXT", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CreateUnixTime", + table: "WeixinReceivedEvents", + type: "INTEGER", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddPrimaryKey( + name: "PK_WeixinSubscribers", + table: "WeixinSubscribers", + column: "OpenId"); + + migrationBuilder.CreateTable( + name: "AuditEntires", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + CreatedTime = table.Column(type: "TEXT", nullable: false), + KeyValue = table.Column(type: "TEXT", nullable: true), + NewValue = table.Column(type: "TEXT", nullable: true), + OldValue = table.Column(type: "TEXT", nullable: true), + TableName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AuditEntires", x => x.Id); + }); + } + } +} diff --git a/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs b/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs index 30bcce9..d6d36bf 100644 --- a/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs +++ b/src/MvcDemo/Migrations/DemoDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ partial class DemoDbContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "6.0.3"); + modelBuilder.HasAnnotation("ProductVersion", "8.0.14"); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { @@ -209,174 +209,141 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserTokens", (string)null); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.AuditEntry", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedEventEntity", b => { b.Property("Id") .HasColumnType("TEXT"); - b.Property("CreatedTime") + b.Property("ConcurrencyStamp") .HasColumnType("TEXT"); - b.Property("KeyValue") - .HasColumnType("TEXT"); + b.Property("CreateTime") + .HasColumnType("INTEGER"); - b.Property("NewValue") + b.Property("Event") .HasColumnType("TEXT"); - b.Property("OldValue") + b.Property("EventKey") .HasColumnType("TEXT"); - b.Property("TableName") + b.Property("FromUserName") .HasColumnType("TEXT"); - b.HasKey("Id"); - - b.ToTable("AuditEntires", (string)null); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry", b => - { - b.Property("Id") + b.Property("Latitude") .HasColumnType("TEXT"); - b.Property("CreateUnixTime") - .HasColumnType("INTEGER"); + b.Property("Longitude") + .HasColumnType("TEXT"); - b.Property("Event") - .IsRequired() + b.Property("MsgType") .HasColumnType("TEXT"); - b.Property("FromUserName") - .IsRequired() - .HasMaxLength(32) + b.Property("Precision") .HasColumnType("TEXT"); - b.Property("MsgType") - .IsRequired() + b.Property("Ticket") .HasColumnType("TEXT"); b.Property("ToUserName") - .IsRequired() - .HasMaxLength(32) .HasColumnType("TEXT"); b.HasKey("Id"); - b.ToTable("WeixinReceivedEvents", (string)null); - - b.HasDiscriminator("Event").HasValue("EventReceivedEntry"); + b.ToTable("WeixinReceivedEvents"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinReceivedMessageEntity", b => { b.Property("Id") .HasColumnType("TEXT"); - b.Property("CreateUnixTime") - .HasColumnType("INTEGER"); + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); - b.Property("FromUserName") - .IsRequired() - .HasMaxLength(32) + b.Property("Content") .HasColumnType("TEXT"); - b.Property("MsgId") + b.Property("CreateTime") .HasColumnType("INTEGER"); - b.Property("MsgType") - .IsRequired() + b.Property("Description") .HasColumnType("TEXT"); - b.Property("ToUserName") - .IsRequired() - .HasMaxLength(32) + b.Property("Format") .HasColumnType("TEXT"); - b.HasKey("Id"); - - b.ToTable("WeixinReceivedMessages", (string)null); - - b.HasDiscriminator("MsgType").HasValue("MessageReceivedEntry"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.Subscriber", b => - { - b.Property("OpenId") - .HasMaxLength(32) + b.Property("FromUserName") .HasColumnType("TEXT"); - b.Property("AppId") + b.Property("Label") .HasColumnType("TEXT"); - b.Property("AvatorImageUrl") + b.Property("Latitude") .HasColumnType("TEXT"); - b.Property("City") + b.Property("Longitude") .HasColumnType("TEXT"); - b.Property("Country") + b.Property("MediaId") .HasColumnType("TEXT"); - b.Property("Gender") + b.Property("MsgId") .HasColumnType("INTEGER"); - b.Property("Language") + b.Property("MsgType") .HasColumnType("TEXT"); - b.Property("MentorId") + b.Property("PicUrl") .HasColumnType("TEXT"); - b.Property("Nickname") + b.Property("Recognition") .HasColumnType("TEXT"); - b.Property("Province") + b.Property("Scale") .HasColumnType("TEXT"); - b.Property("Remark") + b.Property("ThumbMediaId") .HasColumnType("TEXT"); - b.Property("RowVersion") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("BLOB"); + b.Property("Title") + .HasColumnType("TEXT"); - b.Property("SubscribedTime") + b.Property("ToUserName") .HasColumnType("TEXT"); - b.Property("UnionId") - .HasMaxLength(32) + b.Property("Url") .HasColumnType("TEXT"); - b.Property("Unsubscribed") - .IsRequired() - .HasColumnType("INTEGER"); + b.HasKey("Id"); - b.Property("UnsubscribedTime") + b.ToTable("WeixinReceivedMessages"); + }); + + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinResponseMessageEntity", b => + { + b.Property("Id") .HasColumnType("TEXT"); - b.Property("UserId") + b.Property("ConcurrencyStamp") .HasColumnType("TEXT"); - b.HasKey("OpenId"); + b.Property("Content") + .HasColumnType("TEXT"); - b.ToTable("WeixinSubscribers", (string)null); - }); + b.Property("CreateTime") + .HasColumnType("INTEGER"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ClickMenuEventReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); + b.Property("Description") + .HasColumnType("TEXT"); - b.Property("EventKey") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("EventKey"); + b.Property("Format") + .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("CLICK"); - }); + b.Property("FromUserName") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LocationEventReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); + b.Property("Label") + .HasColumnType("TEXT"); b.Property("Latitude") .HasColumnType("TEXT"); @@ -384,175 +351,142 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Longitude") .HasColumnType("TEXT"); - b.Property("Precision") + b.Property("MediaId") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("LOCATION"); - }); + b.Property("MsgId") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.QrscanEventReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); + b.Property("MsgType") + .HasColumnType("TEXT"); - b.Property("EventKey") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("EventKey"); + b.Property("PicUrl") + .HasColumnType("TEXT"); - b.Property("Ticket") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("Ticket"); + b.Property("RequestId") + .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("SCAN"); - }); + b.Property("Scale") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.SubscribeEventReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); + b.Property("ThumbMediaId") + .HasColumnType("TEXT"); - b.Property("EventKey") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("EventKey"); + b.Property("Title") + .HasColumnType("TEXT"); - b.Property("Ticket") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("Ticket"); + b.Property("ToUserName") + .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("subscribe"); - }); + b.Property("Url") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.UnsubscribeEventReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); + b.HasKey("Id"); - b.HasDiscriminator().HasValue("unsubscribe"); + b.ToTable("WeixinResponseMessages"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ViewMenuEventReceivedEntry", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSendMessageEntity", b => { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.EventReceivedEntry"); - - b.Property("EventKey") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("EventKey"); + b.Property("Id") + .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("VIEW"); - }); + b.Property("ConcurrencyStamp") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ImageMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + b.Property("Content") + .HasColumnType("TEXT"); - b.Property("MediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("MediaId"); + b.Property("CreateTime") + .HasColumnType("INTEGER"); - b.Property("PicUrl") + b.Property("FromUserName") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("image"); - }); + b.Property("LastRetCode") + .HasColumnType("INTEGER"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LinkMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + b.Property("LastRetMsg") + .HasColumnType("TEXT"); - b.Property("Description") + b.Property("LastTried") .HasColumnType("TEXT"); - b.Property("Title") + b.Property("RetryTimes") + .HasColumnType("INTEGER"); + + b.Property("ScheduleTime") .HasColumnType("TEXT"); - b.Property("Url") + b.Property("ToUserName") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("link"); + b.HasKey("Id"); + + b.ToTable("WeixinSendMessages"); }); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.LocationMessageReceivedEntry", b => + modelBuilder.Entity("Myvas.AspNetCore.Weixin.WeixinSubscriberEntity", b => { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - - b.Property("Label") + b.Property("Id") .HasColumnType("TEXT"); - b.Property("Latitude") + b.Property("City") .HasColumnType("TEXT"); - b.Property("Longitude") + b.Property("ConcurrencyStamp") .HasColumnType("TEXT"); - b.Property("Scale") + b.Property("Country") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("location"); - }); - - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.ShortVideoMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); - - b.Property("MediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("MediaId"); + b.Property("HeadImgUrl") + .HasColumnType("TEXT"); - b.Property("ThumbMediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("ThumbMediaId"); + b.Property("Language") + .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("shortvideo"); - }); + b.Property("MentorId") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.TextMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + b.Property("Nickname") + .HasColumnType("TEXT"); - b.Property("Content") + b.Property("OpenId") + .HasMaxLength(32) .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("text"); - }); + b.Property("Province") + .HasColumnType("TEXT"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.VideoMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + b.Property("Remark") + .HasColumnType("TEXT"); - b.Property("MediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("MediaId"); + b.Property("SecurityStamp") + .HasColumnType("TEXT"); - b.Property("ThumbMediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("ThumbMediaId"); + b.Property("Sex") + .HasColumnType("INTEGER"); - b.HasDiscriminator().HasValue("video"); - }); + b.Property("SubscribeTime") + .HasColumnType("INTEGER"); - modelBuilder.Entity("Myvas.AspNetCore.Weixin.Models.VoiceMessageReceivedEntry", b => - { - b.HasBaseType("Myvas.AspNetCore.Weixin.Models.MessageReceivedEntry"); + b.Property("Subscribed") + .HasColumnType("INTEGER"); - b.Property("Format") + b.Property("UnionId") + .HasMaxLength(32) .HasColumnType("TEXT"); - b.Property("MediaId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("TEXT") - .HasColumnName("MediaId"); + b.Property("UnsubscribeTime") + .HasColumnType("INTEGER"); - b.Property("Recognition") + b.Property("UserId") .HasColumnType("TEXT"); - b.HasDiscriminator().HasValue("voice"); + b.HasKey("Id"); + + b.ToTable("WeixinSubscribers"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => From 663f7b8edb35e7b37420d2f17b7765a059018301 Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 16:11:48 +0800 Subject: [PATCH 3/9] Show short version --- src/MvcDemo/Program.cs | 5 +++-- src/MvcDemo/Views/Home/Index.cshtml | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/MvcDemo/Program.cs b/src/MvcDemo/Program.cs index 292d50e..fed005b 100644 --- a/src/MvcDemo/Program.cs +++ b/src/MvcDemo/Program.cs @@ -12,8 +12,9 @@ var assembly = typeof(Program).Assembly; var assemblyName = assembly.GetName().Name; -var assemblyVersion = assembly.GetCustomAttribute()?.InformationalVersion; -Log.Information($"{assemblyName} {assemblyVersion} starting up..."); +var assemblyVersion = assembly.GetName().Version?.ToString() + ?? assembly.GetCustomAttribute()?.InformationalVersion; +Log.Information($"{assemblyName} v{assemblyVersion} starting up..."); try { diff --git a/src/MvcDemo/Views/Home/Index.cshtml b/src/MvcDemo/Views/Home/Index.cshtml index dec7fea..71e9c31 100644 --- a/src/MvcDemo/Views/Home/Index.cshtml +++ b/src/MvcDemo/Views/Home/Index.cshtml @@ -1,16 +1,17 @@ @using System.Reflection @{ - ViewData["Title"] = "Demo"; - var assembly = typeof(Program).Assembly; var assemblyName = assembly.GetName().Name; - var assemblyVersion = assembly.GetCustomAttribute()?.InformationalVersion - ?? assembly.GetName().Version.ToString(); + var assemblyVersion = assembly.GetName().Version?.ToString() + ?? assembly.GetCustomAttribute()?.InformationalVersion; + + ViewData["Title"] = assemblyName; } -

@ViewData["Title"] @(assemblyVersion)

+

@assemblyName v@assemblyVersion

-

这是一组github开源项目的演示网站。本网站源代码在此:Myvas.AspNetCore.Authentication.Demo

+

这是一组github开源项目的演示网站。本网站源代码在此:Myvas.AspNetCore.Authentication.Demo

  • WeixinOpen (open.weixin.qq.com)
  • WeixinAuth (mp.weixin.qq.com)
  • @@ -24,12 +25,14 @@

    触发身份验证

    (1)点击UserInfo触发Challenge进入登录页面。

    --- 或 ---

    -

    (2)点击这里展示一个网址二维码,用手机扫码进入。

    +

    (2)点击这里展示一个网址二维码,用手机扫码进入。

    --- 或 ---

    (3)直接扫码进入微信公众号测试,然后点击菜单[UserInfo]

    -

    (注:以上微信公众号的源码在Myvas.AspNetCore.Weixin,其Demo程序可以修改这些菜单)
    +
    (注:以上微信公众号的源码在Myvas.AspNetCore.Weixin,其Demo程序可以修改这些菜单)


    @@ -76,5 +79,6 @@ \ No newline at end of file From ec8b6eaddb1af73252b45e041ce02922b6a8929f Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 16:17:44 +0800 Subject: [PATCH 4/9] Update deploy to echo persistance action --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c54d7a7..e778438 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -50,6 +50,7 @@ jobs: - name: Save the SSH private key to a file run: | if [ ! -f ~/.ssh/id_rsa ]; then + echo "Save the SSH private key to a file" mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa @@ -58,6 +59,7 @@ jobs: - name: Add remote server to known_hosts run: | if ! grep -q "${{ env.SSH_HOST }}" ~/.ssh/known_hosts; then + echo "Add remote server to known_hosts" ssh-keyscan ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts fi From 192cf77be60628f7ba9e621d1a062c21faeec2d4 Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 16:32:49 +0800 Subject: [PATCH 5/9] Refactor MigrateDatabase and SeedData(uid, pwd) --- src/MvcDemo/Data/DemoDbInitializer.cs | 59 ------------ .../Data/DemoDesignTimeDbContextFactory.cs | 16 ---- src/MvcDemo/Data/HostDatabaseExtensions.cs | 52 ----------- .../Data/WebApplicationDatabaseExtensions.cs | 90 +++++++++++++++++++ 4 files changed, 90 insertions(+), 127 deletions(-) delete mode 100644 src/MvcDemo/Data/DemoDbInitializer.cs delete mode 100644 src/MvcDemo/Data/DemoDesignTimeDbContextFactory.cs delete mode 100644 src/MvcDemo/Data/HostDatabaseExtensions.cs create mode 100644 src/MvcDemo/Data/WebApplicationDatabaseExtensions.cs diff --git a/src/MvcDemo/Data/DemoDbInitializer.cs b/src/MvcDemo/Data/DemoDbInitializer.cs deleted file mode 100644 index 722bb84..0000000 --- a/src/MvcDemo/Data/DemoDbInitializer.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Demo.Models; - -namespace Demo.Data -{ - public static class DemoDbInitializer - { - public const string AdminUserName = "demo"; - public const string AdminInitPassword = "demo@myvas.com"; - - public static async Task Initialize(IServiceProvider serviceProvider) - { - using var db = new DemoDbContext(serviceProvider.GetRequiredService>()); - await EnsureAdminUser(serviceProvider); - } - - private static async Task EnsureAdminUser(IServiceProvider serviceProvider) - { - var userManager = serviceProvider.GetRequiredService>(); - - var user = await userManager.FindByNameAsync(AdminUserName); - if (user == null) - { - user = new IdentityUser() - { - UserName = AdminUserName, - Email = "demo@myvas.com", - EmailConfirmed = true, - PhoneNumber = "13800138000", - PhoneNumberConfirmed = true, - }; - var result = await userManager.CreateAsync(user, AdminInitPassword); - if (!result.Succeeded) - { - throw new Exception(GetErrorMessage(result)); - } - } - } - - private static string GetErrorMessage(IdentityResult identityResult) - { - var result = ""; - - foreach (var error in identityResult.Errors) - { - result += $"[{error.Code}]{error.Description}" + Environment.NewLine; - } - return result; - } - - - } -} diff --git a/src/MvcDemo/Data/DemoDesignTimeDbContextFactory.cs b/src/MvcDemo/Data/DemoDesignTimeDbContextFactory.cs deleted file mode 100644 index 94d18b2..0000000 --- a/src/MvcDemo/Data/DemoDesignTimeDbContextFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace Demo.Data -{ - public class DemoDesignTimeDbContextFactory : IDesignTimeDbContextFactory - { - public DemoDbContext CreateDbContext(string[] args) - { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlite("Data Source=demo.sqlite"); - - return new DemoDbContext(optionsBuilder.Options); - } - } -} diff --git a/src/MvcDemo/Data/HostDatabaseExtensions.cs b/src/MvcDemo/Data/HostDatabaseExtensions.cs deleted file mode 100644 index fdcfd03..0000000 --- a/src/MvcDemo/Data/HostDatabaseExtensions.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; - -namespace Demo.Data; - -public static class HostDatabaseExtensions -{ - public static WebApplication MigrateDatabase(this WebApplication host) - { - using (var scope = host.Services.CreateScope()) - { - var services = scope.ServiceProvider; - - try - { - var db = services.GetRequiredService(); - db.Database.Migrate(); - } - catch (Exception ex) - { - var logger = services.GetRequiredService>(); - logger.LogError(ex, "An error occurred while migrating the database."); - } - } - - return host; - } - - public static WebApplication SeedDatabase(this WebApplication host) - { - using (var scope = host.Services.CreateScope()) - { - var services = scope.ServiceProvider; - - try - { - DemoDbInitializer.Initialize(services).Wait(); - } - catch (Exception ex) - { - var logger = services.GetRequiredService>(); - logger.LogError(ex, "An error occurred while seeding the database."); - } - } - - return host; - } -} diff --git a/src/MvcDemo/Data/WebApplicationDatabaseExtensions.cs b/src/MvcDemo/Data/WebApplicationDatabaseExtensions.cs new file mode 100644 index 0000000..65f63be --- /dev/null +++ b/src/MvcDemo/Data/WebApplicationDatabaseExtensions.cs @@ -0,0 +1,90 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Demo.Data; + +public static class WebApplicationDatabaseExtensions +{ + public static WebApplication MigrateDatabase(this WebApplication app) + { + using (var scope = app.Services.CreateScope()) + { + var services = scope.ServiceProvider; + + try + { + var db = services.GetRequiredService(); + db.Database.Migrate(); + } + catch (Exception ex) + { + var logger = services.GetRequiredService>(); + logger.LogError(ex, "An error occurred while migrating the database."); + } + } + + return app; + } + + + public static WebApplication SeedDatabase(this WebApplication app, string adminUserName, string adminInitPassword) + { + using (var scope = app.Services.CreateScope()) + { + var services = scope.ServiceProvider; + + try + { + Task.Run(async () => + { + var userManager = services.GetRequiredService>(); + await EnsureAdminUser(userManager, adminUserName, adminInitPassword); + }); + } + catch (Exception ex) + { + var logger = services.GetRequiredService>(); + logger.LogError(ex, "An error occurred while seeding the database."); + } + } + + return app; + } + + private static async Task EnsureAdminUser(UserManager userManager, string adminUserName, string adminEmail) + { + var adminInitPassword = adminEmail; + + var user = await userManager.FindByNameAsync(adminUserName); + if (user == null) + { + user = new IdentityUser() + { + UserName = adminUserName, + Email = adminEmail, + EmailConfirmed = true, + }; + var result = await userManager.CreateAsync(user, adminInitPassword); + if (!result.Succeeded) + { + throw new Exception(GetErrorMessage(result)); + } + } + } + + private static string GetErrorMessage(IdentityResult identityResult) + { + var result = ""; + + foreach (var error in identityResult.Errors) + { + result += $"[{error.Code}]{error.Description}" + Environment.NewLine; + } + return result; + } +} \ No newline at end of file From 2590a0eac9c991602bd1c9fb739c64edcc575b93 Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 16:33:18 +0800 Subject: [PATCH 6/9] Update to use new db extensions --- src/MvcDemo/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MvcDemo/Program.cs b/src/MvcDemo/Program.cs index fed005b..b34b11b 100644 --- a/src/MvcDemo/Program.cs +++ b/src/MvcDemo/Program.cs @@ -22,7 +22,7 @@ var app = builder.ConfigureServices() .MigrateDatabase() - .SeedDatabase() + .SeedDatabase("demo", "demo@myvas.com") .ConfigurePipeline(); app.Run(); @@ -35,6 +35,6 @@ } finally { - Log.Information($"{assemblyName} {assemblyVersion} shutdown."); + Log.Information($"{assemblyName} v{assemblyVersion} shutdown."); Log.CloseAndFlush(); } From 460e12a3c2b8498794bb27652b60499c5062deaf Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 18:09:43 +0800 Subject: [PATCH 7/9] Add JsapiTicket redis cache provider --- src/MvcDemo/HostExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MvcDemo/HostExtensions.cs b/src/MvcDemo/HostExtensions.cs index 04219b7..81ac6ac 100644 --- a/src/MvcDemo/HostExtensions.cs +++ b/src/MvcDemo/HostExtensions.cs @@ -12,7 +12,7 @@ namespace Demo; public static class HostExtensions { - public static WebApplication ConfigureServices(this WebApplicationBuilder builder) + public static WebApplicationBuilder ConfigureServices(this WebApplicationBuilder builder) { var Configuration = builder.Configuration; @@ -91,6 +91,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde { o.Configuration = Configuration.GetConnectionString("RedisConnection"); }) + .AddJsapiTicketRedisCacheProvider() .AddWeixinSite(o => { o.Debug = true; // for this demo for debugging @@ -105,7 +106,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde }) .AddWeixinEventSink(); - return builder.Build(); + return builder; } public static WebApplication ConfigurePipeline(this WebApplication app) From 4a601a4d899b09030907dceaec0fa31385eaf94f Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 18:10:41 +0800 Subject: [PATCH 8/9] Update to support chain calling on WebApplicationBuilder. --- src/MvcDemo/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MvcDemo/Program.cs b/src/MvcDemo/Program.cs index b34b11b..548c2ec 100644 --- a/src/MvcDemo/Program.cs +++ b/src/MvcDemo/Program.cs @@ -20,7 +20,7 @@ { var builder = WebApplication.CreateBuilder(args); - var app = builder.ConfigureServices() + var app = builder.ConfigureServices().Build() .MigrateDatabase() .SeedDatabase("demo", "demo@myvas.com") .ConfigurePipeline(); From 43e83de58f813ebb2887e2952214f211083407e3 Mon Sep 17 00:00:00 2001 From: FrankH <4848285@qq.com> Date: Tue, 25 Mar 2025 18:11:45 +0800 Subject: [PATCH 9/9] Update to use Myvas.AspNetCore.Weixin 9.0.0-rc.6 --- src/MvcDemo/Demo.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MvcDemo/Demo.csproj b/src/MvcDemo/Demo.csproj index 99dbc3f..edda96a 100644 --- a/src/MvcDemo/Demo.csproj +++ b/src/MvcDemo/Demo.csproj @@ -27,7 +27,7 @@ - +