Skip to content

Commit

Permalink
Update test project
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikEJ committed Dec 21, 2023
1 parent 966b553 commit 37dfc82
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 27 deletions.
11 changes: 0 additions & 11 deletions src/GUI/RevEng.Core.60/Dgml/DatabaseModelToDgml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Constraint> 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();
Expand Down
2 changes: 1 addition & 1 deletion src/GUI/RevEng.Shared/Providers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static List<NuGetPackage> GetNeededPackages(DatabaseType databaseType, bo
packages.Add(new NuGetPackage
{
PackageId = "Dapper",
Version = "2.0.143",
Version = "2.1.24",
DatabaseTypes = new List<DatabaseType> { DatabaseType.SQLServer, DatabaseType.SQLServerDacpac },
IsMainProviderPackage = false,
UseMethodName = null,
Expand Down
3 changes: 3 additions & 0 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public Category()

public int CategoryId { get; set; }
public string CategoryName { get; set; }
/// <summary>
/// Obsolete
/// </summary>
public string Description { get; set; }
public byte[] Image { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class Customer
{
public Customer()
{
Orders = new HashSet<Order>();
OrderLink = new HashSet<Order>();
CustomerTypes = new HashSet<CustomerDemographic>();
}

Expand All @@ -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<Order> Orders { get; set; }
public virtual ICollection<Order> OrderLink { get; set; }

public virtual ICollection<CustomerDemographic> CustomerTypes { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial interface INorthwindContextProcedures
Task<List<CustOrdersOrdersResult>> CustOrdersOrdersAsync(string CustomerID, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<EmployeeSalesbyCountryResult>> EmployeeSalesbyCountryAsync(DateTime? Beginning_Date, DateTime? Ending_Date, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<MultiSetResult>> MultiSetAsync(DateTime? Year, decimal? ProductValue, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<int> OutputScenariosAsync(short? Year, OutputParameter<int?> ProductCount, OutputParameter<string> Description, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<OutputScenariosResult>> OutputScenariosAsync(short? Year, OutputParameter<int?> ProductCount, OutputParameter<string> Description, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<SalesbyYearResult>> SalesbyYearAsync(DateTime? Beginning_Date, DateTime? Ending_Date, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<SalesByCategoryResult>> SalesByCategoryAsync(string CategoryName, string OrdYear, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Task<List<SpecialTypesResult>> SpecialTypesAsync(byte[] Parents, byte[] geo, byte[] geom, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public NorthwindContext(DbContextOptions<NorthwindContext> options)
public virtual DbSet<OrderDetailsExtended> OrderDetailsExtendeds { get; set; }
public virtual DbSet<OrderSubtotal> OrderSubtotals { get; set; }
public virtual DbSet<OrdersQry> OrdersQries { get; set; }
public virtual DbSet<Person> People { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<ProductSalesFor1997> ProductSalesFor1997s { get; set; }
public virtual DbSet<ProductsAboveAveragePrice> ProductsAboveAveragePrices { get; set; }
Expand All @@ -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");
}
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -351,6 +354,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<Order>(entity =>
{
entity.HasComment("Orders table");

entity.HasIndex(e => e.CustomerId, "CustomerID");

entity.HasIndex(e => e.CustomerId, "CustomersOrders");
Expand Down Expand Up @@ -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");

Expand All @@ -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");
Expand Down Expand Up @@ -530,6 +537,27 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.ShippedDate).HasColumnType("datetime");
});

modelBuilder.Entity<Person>(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<Product>(entity =>
{
entity.HasIndex(e => e.CategoryId, "CategoriesProducts");
Expand Down Expand Up @@ -695,6 +723,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<Shipper>(entity =>
{
entity.HasComment("Shipper table comment");

entity.Property(e => e.ShipperId).HasColumnName("ShipperID");

entity.Property(e => e.CompanyName)
Expand All @@ -707,6 +737,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<Special>(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<SummaryOfSalesByQuarter>(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected void OnModelCreatingGeneratedProcedures(ModelBuilder modelBuilder)
modelBuilder.Entity<CustOrdersOrdersResult>().HasNoKey().ToView(null);
modelBuilder.Entity<EmployeeSalesbyCountryResult>().HasNoKey().ToView(null);
modelBuilder.Entity<MultiSetResult>().HasNoKey().ToView(null);
modelBuilder.Entity<OutputScenariosResult>().HasNoKey().ToView(null);
modelBuilder.Entity<SalesbyYearResult>().HasNoKey().ToView(null);
modelBuilder.Entity<SalesByCategoryResult>().HasNoKey().ToView(null);
modelBuilder.Entity<SpecialTypesResult>().HasNoKey().ToView(null);
Expand Down Expand Up @@ -203,7 +204,7 @@ public virtual async Task<List<MultiSetResult>> MultiSetAsync(DateTime? Year, de
return _;
}

public virtual async Task<int> OutputScenariosAsync(short? Year, OutputParameter<int?> ProductCount, OutputParameter<string> Description, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default)
public virtual async Task<List<OutputScenariosResult>> OutputScenariosAsync(short? Year, OutputParameter<int?> ProductCount, OutputParameter<string> Description, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default)
{
var parameterProductCount = new SqlParameter
{
Expand Down Expand Up @@ -239,7 +240,7 @@ public virtual async Task<int> 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<OutputScenariosResult>("EXEC @returnValue = [dbo].[OutputScenarios] @Year, @ProductCount OUTPUT, @Description OUTPUT", sqlParameters, cancellationToken);

ProductCount.SetValue(parameterProductCount.Value);
Description.SetValue(parameterDescription.Value);
Expand Down
3 changes: 3 additions & 0 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace ScaffoldingTester.Models
{
/// <summary>
/// Orders table
/// </summary>
public partial class Order
{
public Order()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace ScaffoldingTester.Models
{
/// <summary>
/// OrderDetails table
/// </summary>
public partial class OrderDetail
{
public int OrderId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace ScaffoldingTester.Models
{
public partial class OutputScenariosResult
{
}
}
16 changes: 16 additions & 0 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
3 changes: 3 additions & 0 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Shipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace ScaffoldingTester.Models
{
/// <summary>
/// Shipper table comment
/// </summary>
public partial class Shipper
{
public Shipper()
Expand Down
3 changes: 3 additions & 0 deletions test/ScaffoldingTester/ScaffoldingTester5/Models/Special.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.9">
<PackageReference Include="Dapper" Version="2.1.24" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.25">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="6.0.25" />
</ItemGroup>

</Project>
13 changes: 11 additions & 2 deletions test/ScaffoldingTester/ScaffoldingTester5/efpt.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"OutputPath": "Models",
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "ScaffoldingTester",
"RemoveValueGeneratedOnAdd": false,
"Schemas": null,
"SelectedHandlebarsLanguage": 0,
"SelectedToBeGenerated": 0,
"T4TemplatePath": null,
"Tables": [
{
"Name": "[dbo].[Categories]",
Expand Down Expand Up @@ -46,6 +48,10 @@
"Name": "[dbo].[Orders]",
"ObjectType": 0
},
{
"Name": "[dbo].[Person]",
"ObjectType": 0
},
{
"Name": "[dbo].[Products]",
"ObjectType": 0
Expand Down Expand Up @@ -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
}

0 comments on commit 37dfc82

Please sign in to comment.