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

Feature Suggestion : Being able to provide type mapping (or templates) for some column #1082

Closed
pedautreppe opened this issue Aug 26, 2021 · 8 comments

Comments

@pedautreppe
Copy link

I am currently working with EFCorePowerTools to reverse engineer a legacy Oracle Database.
I encounter 2 problems with my DB :

To workaround those problem, I will ignore the corresponding column to handle myself :

  • either setting the appropriate type mapping myself for the 1st point (defining the column, and DB mapping configuration)
  • or by settings the appropriate value conversion for the 2nd point

This works perfeclty well, but can be quite cumbersome.

What would be great in the tool :

  • being able to define some code template (eg with handlebar) referencing some token (propertyName, columnName)
  • being able to assign such a template to several column
@ErikEJ
Copy link
Owner

ErikEJ commented Aug 26, 2021

You should report the bad mapping to Oracle @alexkeh

@alexkeh
Copy link

alexkeh commented Aug 26, 2021

In EF Core, provider data type mapping for Migrations and Scaffolding must be the same. Providers cannot provide two different sets of mappings for each operation. That presents a problem when .NET data types are not the same size as Oracle DB data types. Either the migrations or scaffolding mapping will try to save data into a type that is too small.

Since migrations is the more common use case, .NET data types map to larger Oracle DB data types. Of course, that means when scaffolding, the larger DB data types must now map to smaller .NET data types.

The only solution is to manually adjust the type mapping until EF Core itself allows providers to provide two different mappings for scaffolding and migrations.

@ErikEJ
Copy link
Owner

ErikEJ commented Aug 26, 2021

@ajcvickers Is there an issue for this?

@ErikEJ
Copy link
Owner

ErikEJ commented Aug 26, 2021

I think you can assign a value converter to multiple properties in EF Core 6.

@pedautreppe
Copy link
Author

Thanks @alexkeh , makes sense indeed.

I have seen that there is a way to provide a mapping between types.
https://docs.oracle.com/cd/E56485_01/win.121/e55744/entityDataTypeMapping.htm#ODPNT8300

However, I can find the doc only for the .NET framework but I don't find the doc to do it in .NET core.
Do you have any pointer about it ?

If it's possible, that would cleary answer part of my need !

@alexkeh
Copy link

alexkeh commented Aug 26, 2021

@pedautreppe This capability is not available with the current Oracle EF Core provider. There is no longer an app.config, but perhaps it would be possible to load a custom configuration file with mappings.

The key question is whether designing and setting up this extra infrastructure is worth it vs. the manual mapping developers do today. It may not be much of a productivity win compared to the provider work needed.

@ErikEJ
Copy link
Owner

ErikEJ commented Aug 27, 2021

This is not something I plan to support, apart from what you can already do in the partial OnModelCreatingPartial method, and by taking advantage of LINQ query to do batch modelling.

@ErikEJ ErikEJ closed this as completed Aug 27, 2021
@ajcvickers
Copy link

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

4 participants