Code Monkey home page Code Monkey logo

Comments (8)

ErikEJ avatar ErikEJ commented on August 23, 2024 1

@UseMuse Alternative would be to use a T4 template and fix the names there. Seems like a reasonable workaround you have found.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Please provide a schema, options file and expected versus actual results.

from efcorepowertools.

UseMuse avatar UseMuse commented on August 23, 2024
//efpt.config.json
{
  "CodeGenerationMode": 2,
  "ContextClassName": "ReadOnlyMsSqlDbContext",
  "ContextNamespace": "MyApiCore",
  "FilterSchemas": false,
  "IncludeConnectionString": false,
  "ModelNamespace": "MyApiCore",
  "OutputContextPath": "DAL\\MsSql\\DbContext",
  "OutputPath": "DAL\\Entity",
  "PreserveCasingWithRegex": true,
  "ProjectRootNamespace": "",
  "Schemas": null,
  "SelectedHandlebarsLanguage": 0,
  "SelectedToBeGenerated": 0,
  "T4TemplatePath": null,
  "Tables": [
    {
      "Name": "[dbo].[t_tag]",
      "ObjectType": 0
    },
    {
      "Name": "[dbo].[t_Product]",
      "ObjectType": 0
    }
  ],
  "UiHint": null,
  "UncountableWords": null,
  "UseAsyncStoredProcedureCalls": true,
  "UseBoolPropertiesWithoutDefaultSql": true,
  "UseDatabaseNames": true,
  "UseDateOnlyTimeOnly": false,
  "UseDbContextSplitting": false,
  "UseDecimalDataAnnotationForSprocResult": true,
  "UseFluentApiOnly": true,
  "UseHandleBars": true,
  "UseHierarchyId": false,
  "UseInflector": false,
  "UseLegacyPluralizer": false,
  "UseManyToManyEntity": false,
  "UseNoDefaultConstructor": true,
  "UseNoNavigations": true,
  "UseNoObjectFilter": false,
  "UseNodaTime": false,
  "UseNullableReferences": true,
  "UsePrefixNavigationNaming": false,
  "UseSchemaFolders": false,
  "UseSchemaNamespaces": false,
  "UseSpatial": false,
  "UseT4": false
}
//efpt.renaming.json
[
  {
    "SchemaName": "dbo",
    "Tables": [
      {
        "Columns": [
          {
            "Name": "id",
            "NewName": "Id"
          },
          {
            "Name": "title",
            "NewName": "Title"
          }
        ],
        "Name": "t_tag",
        "NewName": "TTag"
      }
    ],
    "UseSchemaName": false
  }
]
CREATE TABLE [dbo].[t_tag](
	[id] [int] NOT NULL,
	[title] [varchar](255) NULL)

CREATE TABLE [dbo].[t_Product](
[ID_Product] [int] NOT NULL,
[Title] [varchar](255) NULL)

Expected result, c# classes

//
    public partial class TTag
    {
        public int Id { get; set; }
        public string? Title { get; set; }
    }
    public partial class t_Product
    {
        public int ID_Product { get; set; }
        public string? Title { get; set; }
    }

Historically, all models in the api project had the same class name as in db ms sql (example t_Product), there was a need to use snake case for all new tables (example t_tag).
How to make the majority use naming rules like "Use table and column name directly from the database"
And the smaller part (new entities in the db) used camel case for c#

The ideal option for me is to continue using "Use table and column name directly from the database" with selective renaming of tables that should be named differently than in the database

I plan to make 2 configuration files efpt.config.json
with the global setting "Run cleanup ..." equal to false
in one configuration file with "Use table and column name directly from the database", in the other file without this option
by running these two files, I will get the expected result, it seems that this should work....

from efcorepowertools.

UseMuse avatar UseMuse commented on August 23, 2024

Are there other ways to achieve the result I need in the current reality?

from efcorepowertools.

UseMuse avatar UseMuse commented on August 23, 2024

@UseMuse Alternative would be to use a T4 template and fix the names there. Seems like a reasonable workaround you have found.

Unfortunately, ef core 6 not supports T4 template, transition to 7 and higher is not planned yet, thanks for the feedback

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Assume you are aware that EF Core 6 goes out of support in November, and EF Core 7 is already out of support?

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

from efcorepowertools.

UseMuse avatar UseMuse commented on August 23, 2024

@ErikEJ

I plan to make 2 configuration files efpt.config.json with the global setting "Run cleanup ..." equal to false in one configuration file with "Use table and column name directly from the database", in the other file without this option by running these two files, I will get the expected result, it seems that this should work....

when using two configuration files with the same context name and executing these configuration files, the context is overwritten, I expected summation, it looks like I'll have to give them different names and somehow combine them into one context, since they should all be accessible through one class and interface when injecting a dependency

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Don't assume summation, this is generated code. You can create partial classes to modify the configuration

from efcorepowertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.