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

Database first - ability to override default type mapping #6263

Closed
Misiu opened this issue Aug 8, 2016 · 3 comments
Closed

Database first - ability to override default type mapping #6263

Misiu opened this issue Aug 8, 2016 · 3 comments

Comments

@Misiu
Copy link

Misiu commented Aug 8, 2016

i have simple table in MS SQL containing 2 columns:
ClientId - binary(8) primary key
ClientName - varchar(30)

When I add that table to my model I can see that ClientId type = Binary

snap 2016-07-29 at 09 26 38

What I would like to do is to override that type so that inside C# code I will be able to use int instead of byte[].

SELECT * FROM Clients WHERE ClientId = 0x0000000000000001 and SELECT * FROM Clients WHERE ClientId = 1 are giving me same results so why not allow to specify target mapping.

This would only require simple CAST inside SQL and just for select operation, all other work fine.

I'm aware I can use stored procedures for select and updates or even use SQL view. But sometimes for very simple applications this would be big convenience.

It's easier to say client with Id = 4067 than client with Id =0x0000000000000FE3

Can this be done?

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 8, 2016

This is the EF Core issue tracker? Are you using EF6 - then the issue tracker is here: https://github.com/aspnet/EntityFramework6/issues

@Misiu
Copy link
Author

Misiu commented Aug 8, 2016

@ErikEJ I thought about posting it there, but as some time I'll move to EF7 so I'd like to have that feature already working when I'll use EF7.

@ajcvickers
Copy link
Member

Type conversions are being tracked by issue #242. Closing this as a duplicate of that issue.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants