Inside SQL I have table that have primary key as binary(8). When I add that table to my model using Update Model from Database I can see that this column has type=Binary
and in C# I get that column as byte[].
Can I map that column to int?
I know I can create a view with CAST in SQL:
SELECT
Client_Id,
CAST(Client_Id AS INT) AS NewClient_Id,
* /*other columns*/
FROM
dbo.Clients
but this isn't a solution, because I must be able to write, not just read from that table. I know I can create stored procedure for inserts but I'd like to avoid that.
I'm usinf EntityFramewor 6.1.3.

binary(8)contains 8 bytes. anintin C# contains 4 bytes. Do you see the problem here?CASTin SQL then maybe EF can do that cast for me. I can convert thatbyte[]to int by myself in code, but I thought that EF has this build in, I just don't know how to turn that on or configure it.0x0000000000000002. I'd like to avoid view and procedures because I want to use same approach (convert binary(8) to int) in existing tables without creating extra 20 views.