ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.11k stars 292 forks source link

incompatibility with character 'ñ' when reverse engineering with Handlebars templates #77

Closed Goldman90 closed 6 years ago

Goldman90 commented 6 years ago

when trying to reverse engineer a DB with a column with the character 'ñ', the character will be translated as "ñ"

Steps to reproduce

create a column in the database with the character 'ñ' (in my case, the column name was "Contraseña") and then reverse engineer the database. The corresponding POCO property will be named "Contraseña"

Further technical details

Version 1.0.604.0

SQL Server Compact 4.0 in GAC - No SQL Server Compact 4.0 DbProvider - No

SQL Server Compact 4.0 DDEX provider - No SQL Server Compact 4.0 Simple DDEX provider - Yes

SQLite ADO.NET Provider included: 1.0.107.0 SQLite EF6 DbProvider in GAC - No

System.Data.SQLite DDEX provider - No SQLite Simple DDEX provider - Yes

Database engine: SQL Server Visual Studio version: vs 2017

ErikEJ commented 6 years ago

I cannot see any difference?

Goldman90 commented 6 years ago

my bad, of course the code translates to "ñ" in most situations: & # 2 4 1 ; (without the spaces)

ErikEJ commented 6 years ago

So this can be closed?

Goldman90 commented 6 years ago

sorry, it seems i'm not making myself clear, in my last post i meant that this page is translating that code to "ñ", but the addon isn't. the result i'm getting when reverse engieniering the field "Contraseña" is this: image

ErikEJ commented 6 years ago

that this page

What page??

Goldman90 commented 6 years ago

What page??

Github

ErikEJ commented 6 years ago

I am not able to reproduce, can you share a SQL script for the table that is causing issues?

Goldman90 commented 6 years ago
USE [Sanitarios]
GO

/****** Object:  Table [dbo].[Usuario]    Script Date: 30/7/2018 18:58:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Usuario](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [NombreUsuario] [nvarchar](250) NOT NULL,
    [Contraseña] [nvarchar](50) NOT NULL,
    [Nombre] [nvarchar](60) NOT NULL,
    [Apellido] [nvarchar](60) NOT NULL,
    [Calle] [nvarchar](100) NULL,
    [NumeroDomicilio] [nvarchar](20) NULL,
    [Depto] [nvarchar](50) NULL,
    [Piso] [nvarchar](50) NULL,
    [Provincia] [smallint] NULL,
    [Localidad] [nvarchar](50) NULL,
    [CUIL] [nvarchar](50) NOT NULL,
    [Email] [nvarchar](255) NULL,
    [FechaIngreso] [date] NOT NULL,
    [TipoJornada] [smallint] NOT NULL,
    [Nro] [int] NOT NULL,
    [TipoUsuario] [smallint] NOT NULL,
    [LocalId] [int] NULL,
 CONSTRAINT [PK_Usuario] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_Locales] FOREIGN KEY([LocalId])
REFERENCES [dbo].[Locales] ([Id])
GO

ALTER TABLE [dbo].[Usuario] CHECK CONSTRAINT [FK_Usuario_Locales]
GO

script in a zip, just in case SQLQuery1.zip

ErikEJ commented 6 years ago

Thanks, still unable to reproduce - can you share a VS project that demonstrates the issue?

Goldman90 commented 6 years ago

while making the project found out, this only happens if using handlebar templates. My bad, should've mentioned that i was using that(for lazy loading). also unrelated, but when using the templates constructors are not being created on the context class

ErikEJ commented 6 years ago

Now you are telling me!! 😄

Please clarify what you mean by this, maybe the templates should be updated:

also unrelated, but when using the templates constructors are not being created on the context class

ErikEJ commented 6 years ago

It is a Handelbars issue! https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/issues/30

Goldman90 commented 6 years ago

awesome, my bad, that should've been the first thing i mentioned, specially considering it's clearly stated that's preview.

what i meant by that was that this code:

public SanitariosContext()
        {
        }

        public SanitariosContext(DbContextOptions<SanitariosContext> options)
            : base(options)
        {
        }

is not being created when using templates.

(SanitariosContext is my dbcontext name)

ErikEJ commented 6 years ago

I suggest you report that in the EF Core Handlebars repo, looks like they are missing from the template:

https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/blob/master/src/EntityFrameworkCore.Scaffolding.Handlebars/CodeTemplates/CSharpDbContext/DbContext.hbs

ErikEJ commented 2 years ago

Fixed in latest daily!