diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Database/Contexts/ContentContext.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Database/Contexts/ContentContext.cs index ca193e7..beadf40 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Database/Contexts/ContentContext.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Database/Contexts/ContentContext.cs @@ -23,7 +23,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(model => { model.HasKey(x => x.Id); - model.HasIndex(x => x.Key).IsUnique(); model.Property(x => x.Key).UseCollation("SQL_Latin1_General_CP1_CS_AS"); }); diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/.gitkeep b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.Designer.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.Designer.cs deleted file mode 100644 index c6970ed..0000000 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.Designer.cs +++ /dev/null @@ -1,220 +0,0 @@ -// -using System; -using EasyMicroservices.ContentsMicroservice.Database.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EasyMicroservices.ContentsMicroservice.Migrations -{ - [DbContext(typeof(ContentContext))] - [Migration("20231019201444_FixCaseSensitive_Key_CategoryEntity")] - partial class FixCaseSensitive_Key_CategoryEntity - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Key") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("Key") - .IsUnique() - .HasFilter("[Key] IS NOT NULL"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.ContentEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("bigint"); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("Data") - .HasColumnType("nvarchar(max)"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LanguageId") - .HasColumnType("bigint"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("LanguageId"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Contents"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("Name") - .IsUnique() - .HasFilter("[Name] IS NOT NULL"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Languages"); - - b.HasData( - new - { - Id = 1L, - CreationDateTime = new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6986), - IsDeleted = false, - Name = "fa-IR" - }, - new - { - Id = 2L, - CreationDateTime = new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6999), - IsDeleted = false, - Name = "en-US" - }); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.ContentEntity", b => - { - b.HasOne("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", "Category") - .WithMany("Contents") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", "Language") - .WithMany("Contents") - .HasForeignKey("LanguageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - - b.Navigation("Language"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", b => - { - b.Navigation("Contents"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", b => - { - b.Navigation("Contents"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.cs deleted file mode 100644 index 077c5c9..0000000 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/20231019201444_FixCaseSensitive_Key_CategoryEntity.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EasyMicroservices.ContentsMicroservice.Migrations -{ - /// - public partial class FixCaseSensitive_Key_CategoryEntity : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Key", - table: "Categories", - type: "nvarchar(450)", - nullable: true, - collation: "SQL_Latin1_General_CP1_CS_AS", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.UpdateData( - table: "Languages", - keyColumn: "Id", - keyValue: 1L, - column: "CreationDateTime", - value: new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6986)); - - migrationBuilder.UpdateData( - table: "Languages", - keyColumn: "Id", - keyValue: 2L, - column: "CreationDateTime", - value: new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6999)); - - migrationBuilder.CreateIndex( - name: "IX_Categories_Key", - table: "Categories", - column: "Key", - unique: true, - filter: "[Key] IS NOT NULL"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_Categories_Key", - table: "Categories"); - - migrationBuilder.AlterColumn( - name: "Key", - table: "Categories", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(450)", - oldNullable: true, - oldCollation: "SQL_Latin1_General_CP1_CS_AS"); - - migrationBuilder.UpdateData( - table: "Languages", - keyColumn: "Id", - keyValue: 1L, - column: "CreationDateTime", - value: new DateTime(2023, 8, 31, 17, 37, 24, 623, DateTimeKind.Local).AddTicks(8580)); - - migrationBuilder.UpdateData( - table: "Languages", - keyColumn: "Id", - keyValue: 2L, - column: "CreationDateTime", - value: new DateTime(2023, 8, 31, 17, 37, 24, 623, DateTimeKind.Local).AddTicks(8591)); - } - } -} diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/ContentContextModelSnapshot.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/ContentContextModelSnapshot.cs deleted file mode 100644 index e426d21..0000000 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Database/Migrations/ContentContextModelSnapshot.cs +++ /dev/null @@ -1,217 +0,0 @@ -// -using System; -using EasyMicroservices.ContentsMicroservice.Database.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EasyMicroservices.ContentsMicroservice.Migrations -{ - [DbContext(typeof(ContentContext))] - partial class ContentContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Key") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("Key") - .IsUnique() - .HasFilter("[Key] IS NOT NULL"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.ContentEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("bigint"); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("Data") - .HasColumnType("nvarchar(max)"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LanguageId") - .HasColumnType("bigint"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("LanguageId"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Contents"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreationDateTime") - .HasColumnType("datetime2"); - - b.Property("DeletedDateTime") - .HasColumnType("datetime2"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModificationDateTime") - .HasColumnType("datetime2"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("UniqueIdentity") - .HasColumnType("nvarchar(450)") - .UseCollation("SQL_Latin1_General_CP1_CS_AS"); - - b.HasKey("Id"); - - b.HasIndex("CreationDateTime"); - - b.HasIndex("DeletedDateTime"); - - b.HasIndex("IsDeleted"); - - b.HasIndex("ModificationDateTime"); - - b.HasIndex("Name") - .IsUnique() - .HasFilter("[Name] IS NOT NULL"); - - b.HasIndex("UniqueIdentity"); - - b.ToTable("Languages"); - - b.HasData( - new - { - Id = 1L, - CreationDateTime = new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6986), - IsDeleted = false, - Name = "fa-IR" - }, - new - { - Id = 2L, - CreationDateTime = new DateTime(2023, 10, 19, 23, 44, 44, 432, DateTimeKind.Local).AddTicks(6999), - IsDeleted = false, - Name = "en-US" - }); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.ContentEntity", b => - { - b.HasOne("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", "Category") - .WithMany("Contents") - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", "Language") - .WithMany("Contents") - .HasForeignKey("LanguageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Category"); - - b.Navigation("Language"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.CategoryEntity", b => - { - b.Navigation("Contents"); - }); - - modelBuilder.Entity("EasyMicroservices.ContentsMicroservice.Database.Entities.LanguageEntity", b => - { - b.Navigation("Contents"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs index 28d0aee..1a4d081 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs @@ -20,8 +20,8 @@ public DatabaseBuilder(IConfiguration configuration) public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseInMemoryDatabase("ContentDatabase"); - //optionsBuilder.UseSqlServer(_configuration.GetConnectionString("local")); + //optionsBuilder.UseInMemoryDatabase("ContentDatabase"); + optionsBuilder.UseSqlServer(_configuration.GetConnectionString("local")); } } } diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.Development.json b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.Development.json index 656e154..65d0fc6 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.Development.json +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.Development.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "local": "Server=testtt;Database=Contents;User ID=TrustServerCertificate=True;" // Test + "local": "Server=.;Database=Contents;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" }, "RootAddresses": { "WhiteLabel": "http://localhost:1041" diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json index b1fe191..65d0fc6 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "local": "Server=testtt;Database=Contents;User ID=TrustServerCertificate=True;", // Test + "local": "Server=.;Database=Contents;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" }, "RootAddresses": { "WhiteLabel": "http://localhost:1041"