From 37dfc82d8ca7f9a50485c2d5592c4659af2eb9d2 Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Thu, 21 Dec 2023 08:09:59 +0100 Subject: [PATCH] Update test project --- .../Dgml/DatabaseModelToDgml.cs | 11 ----- src/GUI/RevEng.Shared/Providers.cs | 2 +- .../ScaffoldingTester5/Models/Category.cs | 3 ++ .../ScaffoldingTester5/Models/Customer.cs | 6 +-- .../Models/INorthwindContextProcedures.cs | 2 +- .../Models/NorthwindContext.cs | 44 +++++++++++++++++-- .../Models/NorthwindContextProcedures.cs | 5 ++- .../ScaffoldingTester5/Models/Order.cs | 3 ++ .../ScaffoldingTester5/Models/OrderDetail.cs | 3 ++ .../Models/OutputScenariosResult.cs | 11 +++++ .../ScaffoldingTester5/Models/Person.cs | 16 +++++++ .../Models/SalesByCategoryResult.cs | 1 + .../ScaffoldingTester5/Models/Shipper.cs | 3 ++ .../ScaffoldingTester5/Models/Special.cs | 3 ++ .../ScaffoldingTester5.csproj | 6 +-- .../ScaffoldingTester5/efpt.config.json | 13 +++++- 16 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 test/ScaffoldingTester/ScaffoldingTester5/Models/OutputScenariosResult.cs create mode 100644 test/ScaffoldingTester/ScaffoldingTester5/Models/Person.cs diff --git a/src/GUI/RevEng.Core.60/Dgml/DatabaseModelToDgml.cs b/src/GUI/RevEng.Core.60/Dgml/DatabaseModelToDgml.cs index 82f6f83e0..a57c17bcb 100644 --- a/src/GUI/RevEng.Core.60/Dgml/DatabaseModelToDgml.cs +++ b/src/GUI/RevEng.Core.60/Dgml/DatabaseModelToDgml.cs @@ -90,17 +90,6 @@ public void CreateDgml() var target = $"{key.PrincipalTable.Name}_{key.PrincipalColumns[0].Name}"; dgmlHelper.WriteLink(source, target, key.Name, "Foreign Key"); } - - //// List foreignKeys = _allForeignKeys.Where(c => c.ConstraintTableName == table).ToList(); - //// foreach (Constraint key in foreignKeys) - //// { - //// var col = key.Columns[0]; - //// col = RemoveBrackets(col); - //// var uniqueCol = key.UniqueColumns[0]; - //// uniqueCol = RemoveBrackets(uniqueCol); - //// string source = string.Format("{0}_{1}", table, col); - //// string target = string.Format("{0}_{1}", key.UniqueConstraintTableName, uniqueCol); - //// dgmlHelper.WriteLink(source, target, key.ConstraintName, "Foreign Key"); } dgmlHelper.EndElement(); diff --git a/src/GUI/RevEng.Shared/Providers.cs b/src/GUI/RevEng.Shared/Providers.cs index 3de9ceb2c..1d8068e89 100644 --- a/src/GUI/RevEng.Shared/Providers.cs +++ b/src/GUI/RevEng.Shared/Providers.cs @@ -210,7 +210,7 @@ public static List GetNeededPackages(DatabaseType databaseType, bo packages.Add(new NuGetPackage { PackageId = "Dapper", - Version = "2.0.143", + Version = "2.1.24", DatabaseTypes = new List { DatabaseType.SQLServer, DatabaseType.SQLServerDacpac }, IsMainProviderPackage = false, UseMethodName = null, diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Category.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Category.cs index 759f8be7f..1d24814af 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/Category.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Category.cs @@ -14,6 +14,9 @@ public Category() public int CategoryId { get; set; } public string CategoryName { get; set; } + /// + /// Obsolete + /// public string Description { get; set; } public byte[] Image { get; set; } diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Customer.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Customer.cs index c0133e607..773b2fb89 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/Customer.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Customer.cs @@ -9,7 +9,7 @@ public partial class Customer { public Customer() { - Orders = new HashSet(); + OrderLink = new HashSet(); CustomerTypes = new HashSet(); } @@ -21,12 +21,12 @@ public Customer() public string City { get; set; } public string Region { get; set; } public string PostalCode { get; set; } - public string Country { get; set; } + public string CountryRef { get; set; } public string Phone { get; set; } public string Fax { get; set; } public int Rating { get; set; } - public virtual ICollection Orders { get; set; } + public virtual ICollection OrderLink { get; set; } public virtual ICollection CustomerTypes { get; set; } } diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/INorthwindContextProcedures.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/INorthwindContextProcedures.cs index 5f0f8e572..f1975a397 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/INorthwindContextProcedures.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/INorthwindContextProcedures.cs @@ -18,7 +18,7 @@ public partial interface INorthwindContextProcedures Task> CustOrdersOrdersAsync(string CustomerID, OutputParameter returnValue = null, CancellationToken cancellationToken = default); Task> EmployeeSalesbyCountryAsync(DateTime? Beginning_Date, DateTime? Ending_Date, OutputParameter returnValue = null, CancellationToken cancellationToken = default); Task> MultiSetAsync(DateTime? Year, decimal? ProductValue, OutputParameter returnValue = null, CancellationToken cancellationToken = default); - Task OutputScenariosAsync(short? Year, OutputParameter ProductCount, OutputParameter Description, OutputParameter returnValue = null, CancellationToken cancellationToken = default); + Task> OutputScenariosAsync(short? Year, OutputParameter ProductCount, OutputParameter Description, OutputParameter returnValue = null, CancellationToken cancellationToken = default); Task> SalesbyYearAsync(DateTime? Beginning_Date, DateTime? Ending_Date, OutputParameter returnValue = null, CancellationToken cancellationToken = default); Task> SalesByCategoryAsync(string CategoryName, string OrdYear, OutputParameter returnValue = null, CancellationToken cancellationToken = default); Task> SpecialTypesAsync(byte[] Parents, byte[] geo, byte[] geom, OutputParameter returnValue = null, CancellationToken cancellationToken = default); diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContext.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContext.cs index 663d5627c..c0b38a31e 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContext.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContext.cs @@ -32,6 +32,7 @@ public NorthwindContext(DbContextOptions options) public virtual DbSet OrderDetailsExtendeds { get; set; } public virtual DbSet OrderSubtotals { get; set; } public virtual DbSet OrdersQries { get; set; } + public virtual DbSet People { get; set; } public virtual DbSet Products { get; set; } public virtual DbSet ProductSalesFor1997s { get; set; } public virtual DbSet ProductsAboveAveragePrices { get; set; } @@ -52,7 +53,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) if (!optionsBuilder.IsConfigured) { #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. - optionsBuilder.UseSqlServer("Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"); + optionsBuilder.UseSqlServer("Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True;Encrypt=True"); } } @@ -93,7 +94,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .IsRequired() .HasMaxLength(15); - entity.Property(e => e.Description).HasColumnType("ntext"); + entity.Property(e => e.Description) + .HasColumnType("ntext") + .HasComment("Obsolete"); entity.Property(e => e.Image) .HasColumnType("image") @@ -155,7 +158,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.ContactTitle).HasMaxLength(30); - entity.Property(e => e.Country).HasMaxLength(15); + entity.Property(e => e.CountryRef).HasMaxLength(15); entity.Property(e => e.Fax).HasMaxLength(24); @@ -351,6 +354,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { + entity.HasComment("Orders table"); + entity.HasIndex(e => e.CustomerId, "CustomerID"); entity.HasIndex(e => e.CustomerId, "CustomersOrders"); @@ -399,7 +404,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.ShippedDate).HasColumnType("datetime"); entity.HasOne(d => d.Customer) - .WithMany(p => p.Orders) + .WithMany(p => p.OrderLink) .HasForeignKey(d => d.CustomerId) .HasConstraintName("FK_Orders_Customers"); @@ -421,6 +426,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.ToTable("Order Details"); + entity.HasComment("OrderDetails table"); + entity.HasIndex(e => e.OrderId, "OrderID"); entity.HasIndex(e => e.OrderId, "OrdersOrder_Details"); @@ -530,6 +537,27 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.ShippedDate).HasColumnType("datetime"); }); + modelBuilder.Entity(entity => + { + entity.ToTable("Person"); + + entity.Property(e => e.Address) + .HasMaxLength(255) + .IsUnicode(false); + + entity.Property(e => e.City) + .HasMaxLength(255) + .IsUnicode(false); + + entity.Property(e => e.FirstName) + .HasMaxLength(255) + .IsUnicode(false); + + entity.Property(e => e.LastName) + .HasMaxLength(255) + .IsUnicode(false); + }); + modelBuilder.Entity(entity => { entity.HasIndex(e => e.CategoryId, "CategoriesProducts"); @@ -695,6 +723,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { + entity.HasComment("Shipper table comment"); + entity.Property(e => e.ShipperId).HasColumnName("ShipperID"); entity.Property(e => e.CompanyName) @@ -707,6 +737,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { entity.Property(e => e.Id).ValueGeneratedNever(); + + entity.Property(e => e.Testname) + .HasMaxLength(128) + .HasColumnName("testname"); + + entity.Property(e => e.TheDate).HasColumnType("date"); }); modelBuilder.Entity(entity => diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContextProcedures.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContextProcedures.cs index be1d9e8da..d4fda035c 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContextProcedures.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/NorthwindContextProcedures.cs @@ -40,6 +40,7 @@ protected void OnModelCreatingGeneratedProcedures(ModelBuilder modelBuilder) modelBuilder.Entity().HasNoKey().ToView(null); modelBuilder.Entity().HasNoKey().ToView(null); modelBuilder.Entity().HasNoKey().ToView(null); + modelBuilder.Entity().HasNoKey().ToView(null); modelBuilder.Entity().HasNoKey().ToView(null); modelBuilder.Entity().HasNoKey().ToView(null); modelBuilder.Entity().HasNoKey().ToView(null); @@ -203,7 +204,7 @@ public virtual async Task> MultiSetAsync(DateTime? Year, de return _; } - public virtual async Task OutputScenariosAsync(short? Year, OutputParameter ProductCount, OutputParameter Description, OutputParameter returnValue = null, CancellationToken cancellationToken = default) + public virtual async Task> OutputScenariosAsync(short? Year, OutputParameter ProductCount, OutputParameter Description, OutputParameter returnValue = null, CancellationToken cancellationToken = default) { var parameterProductCount = new SqlParameter { @@ -239,7 +240,7 @@ public virtual async Task OutputScenariosAsync(short? Year, OutputParameter parameterDescription, parameterreturnValue, }; - var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[OutputScenarios] @Year, @ProductCount OUTPUT, @Description OUTPUT", sqlParameters, cancellationToken); + var _ = await _context.SqlQueryAsync("EXEC @returnValue = [dbo].[OutputScenarios] @Year, @ProductCount OUTPUT, @Description OUTPUT", sqlParameters, cancellationToken); ProductCount.SetValue(parameterProductCount.Value); Description.SetValue(parameterDescription.Value); diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Order.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Order.cs index 58deedd1f..8144aa8c8 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/Order.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Order.cs @@ -5,6 +5,9 @@ namespace ScaffoldingTester.Models { + /// + /// Orders table + /// public partial class Order { public Order() diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/OrderDetail.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/OrderDetail.cs index 03c82de83..632dc0ae7 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/OrderDetail.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/OrderDetail.cs @@ -5,6 +5,9 @@ namespace ScaffoldingTester.Models { + /// + /// OrderDetails table + /// public partial class OrderDetail { public int OrderId { get; set; } diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/OutputScenariosResult.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/OutputScenariosResult.cs new file mode 100644 index 000000000..a77bc9f57 --- /dev/null +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/OutputScenariosResult.cs @@ -0,0 +1,11 @@ +// This file has been auto generated by EF Core Power Tools. +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ScaffoldingTester.Models +{ + public partial class OutputScenariosResult + { + } +} diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Person.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Person.cs new file mode 100644 index 000000000..fc726e9ff --- /dev/null +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Person.cs @@ -0,0 +1,16 @@ +// This file has been auto generated by EF Core Power Tools. +#nullable disable +using System; +using System.Collections.Generic; + +namespace ScaffoldingTester.Models +{ + public partial class Person + { + public int Id { get; set; } + public string LastName { get; set; } + public string FirstName { get; set; } + public string Address { get; set; } + public string City { get; set; } + } +} \ No newline at end of file diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/SalesByCategoryResult.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/SalesByCategoryResult.cs index 0e977b177..5f02a59f2 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/SalesByCategoryResult.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/SalesByCategoryResult.cs @@ -8,6 +8,7 @@ namespace ScaffoldingTester.Models public partial class SalesByCategoryResult { public string ProductName { get; set; } + [Column("TotalPurchase", TypeName = "decimal(38,2)")] public decimal? TotalPurchase { get; set; } } } diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Shipper.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Shipper.cs index fb7508e81..252cebb11 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/Shipper.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Shipper.cs @@ -5,6 +5,9 @@ namespace ScaffoldingTester.Models { + /// + /// Shipper table comment + /// public partial class Shipper { public Shipper() diff --git a/test/ScaffoldingTester/ScaffoldingTester5/Models/Special.cs b/test/ScaffoldingTester/ScaffoldingTester5/Models/Special.cs index 10577bd1a..afd5d7cd9 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/Models/Special.cs +++ b/test/ScaffoldingTester/ScaffoldingTester5/Models/Special.cs @@ -8,5 +8,8 @@ namespace ScaffoldingTester.Models public partial class Special { public int Id { get; set; } + public DateTime? TheDate { get; set; } + public TimeSpan? TheTime { get; set; } + public string Testname { get; set; } } } \ No newline at end of file diff --git a/test/ScaffoldingTester/ScaffoldingTester5/ScaffoldingTester5.csproj b/test/ScaffoldingTester/ScaffoldingTester5/ScaffoldingTester5.csproj index 506a68ca8..1ebbd460a 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/ScaffoldingTester5.csproj +++ b/test/ScaffoldingTester/ScaffoldingTester5/ScaffoldingTester5.csproj @@ -6,12 +6,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/ScaffoldingTester/ScaffoldingTester5/efpt.config.json b/test/ScaffoldingTester/ScaffoldingTester5/efpt.config.json index 18649798a..3dfd0f52f 100644 --- a/test/ScaffoldingTester/ScaffoldingTester5/efpt.config.json +++ b/test/ScaffoldingTester/ScaffoldingTester5/efpt.config.json @@ -10,9 +10,11 @@ "OutputPath": "Models", "PreserveCasingWithRegex": true, "ProjectRootNamespace": "ScaffoldingTester", + "RemoveValueGeneratedOnAdd": false, "Schemas": null, "SelectedHandlebarsLanguage": 0, "SelectedToBeGenerated": 0, + "T4TemplatePath": null, "Tables": [ { "Name": "[dbo].[Categories]", @@ -46,6 +48,10 @@ "Name": "[dbo].[Orders]", "ObjectType": 0 }, + { + "Name": "[dbo].[Person]", + "ObjectType": 0 + }, { "Name": "[dbo].[Products]", "ObjectType": 0 @@ -188,23 +194,26 @@ "ObjectType": 2 } ], - "UiHint": "DG-PF2WPPLD\\SQLEXPRESS.Northwind", + "UiHint": "dg-pf2wppld\\sqlexpress.Northwind.dbo", + "UncountableWords": null, "UseBoolPropertiesWithoutDefaultSql": true, "UseDatabaseNames": false, + "UseDateOnlyTimeOnly": false, "UseDbContextSplitting": false, + "UseDecimalDataAnnotationForSprocResult": true, "UseFluentApiOnly": true, "UseHandleBars": false, "UseHierarchyId": false, "UseInflector": true, "UseLegacyPluralizer": false, "UseManyToManyEntity": false, - "UseNoConstructor": false, "UseNoDefaultConstructor": false, "UseNoNavigations": false, "UseNoObjectFilter": false, "UseNodaTime": false, "UseNullableReferences": false, "UseSchemaFolders": false, + "UseSchemaNamespaces": false, "UseSpatial": false, "UseT4": false } \ No newline at end of file