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

Reverse engineering - Tables not mapped, tables names contains danish characters #557

Closed
mikaelbnielsen opened this issue Nov 3, 2020 · 21 comments

Comments

@mikaelbnielsen
Copy link

Hi Erik

First of all, thanks for a nice tool.

When i reverse engineer a database, some tables are not mapped.

After a closer look, i suspect the problem is the tables contains an letter 'æ' in the name

Do you have an workaround on this ?

Does the power tool provide an output log for helping identifying the issue ?

Thank you in advance

Regards
Mikael

Further technical details

EF Core Power Tools version: 2.4.217.0

Database engine: SQL Server 14.0.2027.2

Visual Studio version: Visual Studio 2019 16.7.7

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 3, 2020

Please share a create table script for the unmapped table.

Something is causing it to be excluded, and therefore no errors are logged.

@mikaelbnielsen
Copy link
Author

Database and table sql:
CREATE DATABASE [testdb]
GO

create schema MySchema
GO

CREATE TABLE [MySchema].[MinÆndring](
[Id] [int] IDENTITY(1,1) NOT NULL,
[FK_StatusTypeId] [int] NOT NULL
CONSTRAINT [PK_MinÆndring] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO

The generated context

// This file has been auto generated by EF Core Power Tools.
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace MyNameSpace.Models2
{
public partial class MyContext : DbContext
{
public MyContext()
{
}

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

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

}

How to reproduce

2020-11-04 09_44_30-Generate EF Core Model in Project repository
2020-11-04 09_46_47-Repository - Microsoft Visual Studio
2020-11-04 09_20_10-Choose Database Connection
2020-11-04 09_43_18-Select Tables to Script

It looks like the UI does not support the danish character

@mikaelbnielsen
Copy link
Author

mikaelbnielsen commented Nov 4, 2020 via email

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

Unable to reproduce, works fine on my DB 😄

What is your database collation? Mine is: SQL_Latin1_General_CP1_CI_AS

@mikaelbnielsen
Copy link
Author

Hopefully it is just setting then ;-)

I am using Danish_Norwegian_CI_AS.

I have just tried SQL_Latin1_General_CP1_CI_AS, but with the same result.

2020-11-04 13_04_41-Select Tables to Script
2020-11-04 13_06_58-Database Properties - testdb2

All my settings is set to danish, and the sql server is running on the same local computer

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

Please try to run (from %temp% folder)

efreveng.exe 3 "Data Source=(local);Initial Catalog=MyDatabase;Integrated Security=true" 

and share the output - it could be an issue with console output encoding.

(https://stackoverflow.com/questions/2062875/show-utf-8-characters-in-console )

@ErikEJ ErikEJ closed this as completed in a5eb1bb Nov 4, 2020
@ErikEJ ErikEJ reopened this Nov 4, 2020
@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

Hi, I have attempted a fix in the latest daily build: https://github.com/ErikEJ/EFCorePowerTools/wiki/Release-notes

@mikaelbnielsen
Copy link
Author

mikaelbnielsen commented Nov 4, 2020

Here is the output for both databases with different collations

2020-11-04 14_17_53-C__WINDOWS_system32_cmd exe

I will go test you daily build right away.

@mikaelbnielsen
Copy link
Author

Version 2.5.272.0

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

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

No, the daily build did not solve the problem.

2020-11-04 14_42_15-Window
2020-11-04 14_43_02-Window

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

But the encoding made a difference, though!

what is your default codepage - type:

 chcp 

from a cmd prompt

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

I have just updated the daily build, maybe I set the output encoding in the wrong end of the pipeline.

@mikaelbnielsen
Copy link
Author

Hi again

Yes, it did change, my code page is 850

2020-11-04 15_33_31-Window

I will try installing the new build.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

Thanks, I can now try to repro with that code page set.

@mikaelbnielsen
Copy link
Author

Version 2.5.273.0

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

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

Hi again

Now it looks much better, the table is now mapped correct into the class

But now there is some C# 8.0 code in the generated code
2020-11-04 15_41_57-Window

I am using entityframework core in a .net standard 2.0 project.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

What prevents you from using C# 8?

@mikaelbnielsen
Copy link
Author

I am using the .net standard repository project in some .net 4.8 projects, so i can't change the version from 2.0 to 2.1.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

There probably something I missed - so C# 8 does not work with .NET Standard 2.0 projects??

@mikaelbnielsen
Copy link
Author

Hi again

.net standard 2.0 supports c# 7.3
.net standard 2.1 supports c# 8.0

Reference
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version

.net standard 2.0 project can be used in .net framework 4.6.1.
.net standard 2.1 project can not be used in .net framework projects.

Reference
https://docs.microsoft.com/en-us/dotnet/standard/net-standard

We are on the way to migrate to the new versions, but there is a lot of work ahead of us, so for now we are locked with the 4.8 projects.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

I will fix this, thanks for the info!

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 4, 2020

Fixet i seneste build - tak for hjælpen!

@mikaelbnielsen
Copy link
Author

Selv tak og tak for hurtigt respons.

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