Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Incorporating Handlebars to use schema folders. #562

Closed
chassq opened this issue Nov 6, 2020 · 4 comments
Closed

Question: Incorporating Handlebars to use schema folders. #562

chassq opened this issue Nov 6, 2020 · 4 comments

Comments

@chassq
Copy link

chassq commented Nov 6, 2020

Per the docs at https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars we are supposed to be able to set options.EnableSchemaFolders = true; (see example) but EF Power Tools does not seem to honor this maybe? Any ideas on what we may be doing wrong? We looked at the wiki and saw several issues but it is still not quite clear to us what route to take?

#488 (comment)
#290 (comment)
https://gist.github.com/hastarin/7e61d262171a73ec95fe938abf729085

For example creating this rename json file manually would not scale for us but there was mention of a tool to do this. Just not clear to us how to implement?

We have a class library

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <OutputType>Library</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="EntityFrameworkCore.Scaffolding.Handlebars" Version="5.0.0-rc.2" />
    <PackageReference Include="ErikEJ.EntityFrameworkCore.DgmlBuilder" Version="3.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-rc.2.20475.6">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Context\" />
    <Folder Include="Model\" />
  </ItemGroup>

</Project>

It contains a class file to add handlebars services.

    public class ScaffoldingDesignTimeServices : IDesignTimeServices
    {
        public void ConfigureDesignTimeServices(IServiceCollection services)
        {
            //var options = ReverseEngineerOptions.DbContextAndEntities;
            services.AddHandlebarsScaffolding(options =>
            {
                //options.ReverseEngineerOptions = ReverseEngineerOptions.DbContextAndEntities;
                options.EnableSchemaFolders = true;
                //options.EnableNullableReferenceTypes = true;
            });
        }
    }

We are setting Reverse Engineer for Power Tools as:

  1. Connection to DB
  2. Using Net 5 (preview)
  3. See json settings:
{
   "ContextClassName": "AppDbContext",
   "ContextNamespace": null,
   "DefaultDacpacSchema": null,
   "FilterSchemas": false,
   "IncludeConnectionString": true,
   "ModelNamespace": null,
   "OutputContextPath": "Context",
   "OutputPath": "Model",
   "ProjectRootNamespace": "OneMarket.Srv.Dal.Sql",
   "Schemas": null,
   "SelectedHandlebarsLanguage": 0,
   "SelectedToBeGenerated": 0,
   "Tables": [
      {
         "HasPrimaryKey": true,
         "Name": "[scAccess].[IdentityDeviceFlowCode]",
         "ObjectType": 0
      },
      {
         "HasPrimaryKey": true,
         "Name": "[scAccess].[IdentityPersistedGrant]",
         "ObjectType": 0
      },
      {
         "HasPrimaryKey": true,
         "Name": "[scContactPoint].[ContactPoint]",
         "ObjectType": 0
      },
      {
         "HasPrimaryKey": true,
         "Name": "[scContactPoint].[ContactPointAddress]",
         "ObjectType": 0
      }
   ],
   "UseDatabaseNames": true,
   "UseDbContextSplitting": false,
   "UseFluentApiOnly": true,
   "UseHandleBars": true,
   "UseInflector": false,
   "UseLegacyPluralizer": false,
   "UseNodaTime": false,
   "UseSpatial": false
}

We are using the following:
Microsoft Visual Studio Enterprise 2019 Preview
Version 16.8.0 Preview 6.0
VisualStudio.16.Preview/16.8.0-pre.6.0+30626.31
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Visual C++ 2019 00435-60000-00000-AA196
Microsoft Visual C++ 2019

ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 2019 16.8.548.22527
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services 16.1.0.2051307+8b3a790c543a3ce99e92c63a4769988a6a95eddf
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019 16.8.548.22527
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.8.548.22527
Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.6.2000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 16.8.548.22527
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.2000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

Bundler & Minifier 2.8.396
Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.

C# Tools 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Entity Framework Core Power Tools 2.5
Adds useful design-time EF Core DbContext features to the Visual Studio Solution Explorer context menu.

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

GhostDoc 20.2.20270.0
Generate XML Comments from your code, maintain clean and up-to-date documentation, produce help documentation in multiple formats, use intelligent source code Spell Checker in Visual Studio.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure HDInsight Azure Node 2.6.2000.0
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.6.2000.0
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 16.0
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.6.2000.0
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

NuGet Package Manager 5.8.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension 1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62010.06180
Microsoft SQL Server Data Tools

SQLite & SQL Server Compact Toolbox 4.7
SQLite & SQL Server Compact Toolbox adds scripting, import, export, rename, query execution and much more to SQL Server Compact & SQLite Data Connections.

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 16.0.21016.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions 1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes 1.0
Visual Studio Tools for Kubernetes

Web Compiler 1.12.394
Compiler for LESS, Sass and CoffeeScript files

Further technical details

Azure SQL Server

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 6, 2020

Not currently possible, duplicate of #158

@ErikEJ ErikEJ closed this as completed Nov 6, 2020
@chassq
Copy link
Author

chassq commented Nov 6, 2020

Ok just to clarify you say "Not currently possible" but based on the other issue #158 you are awaiting PRs and will not be doing this yourself. Is that about right? Just want to make sure this is not already in the works.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 6, 2020

Correct, that about sums it up... Also, #158 has a measly 2 upvotes

@chassq
Copy link
Author

chassq commented Nov 6, 2020

Ok thanks! Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants