Entity Framework and System.Guid

Entity Framework and System.Guid

Postby robymes » Tue 09 Sep 2008 09:53

Hello,
I'd like to know if is there some support for System.Guid data type.
Usually in Oracle Guids are stored in a RAW(16) field. In OraDirect.NET that type of field is automatically mapped with a System.Byte[16] and it's not possible to change it manually to System.Guid because of a compilation error. Not only, if that field is also a primary key, the table is not mapped at all.
I'm using the current trial version, for us it's very important to have System.Guid support because for multitenancy we use System.Guid as data type for primary keys.

thanks in advance
robymes
 
Posts: 29
Joined: Tue 09 Sep 2008 09:46

Postby Shalex » Tue 09 Sep 2008 15:26

If you want to use Guid with Oracle now, we recommend you to store it in char(36). String types, as opposed to binary types, can be a part of primary key in Entity Framework. After generation of a *.edmx file, open it in XML-editor and change definitions of columns you are interested in. Delete unnecessary attributes and replace Type value:






Don't forget to leave Nullable="false" attribute, if it was before.

In the future releases we also consider the possibility of additional configuration form, that will make available to set the mode when EDM Wizard associate Guid type for char(36) columns.
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44

Postby robymes » Tue 09 Sep 2008 15:58

char(36) it's not a good idea.
let me explain: an ID field with a primary key as a char(36) is very bad for performance. the best option is raw(16) that is a real binary data type.
I hope you will switch to raw(16) as soon as possible also because this is the way oracle supports guid (they use the system fìunction SYS_GUID that returns a raw(16) binary data).

hope for the next version of OraDirect.NET

thanks
robymes
 
Posts: 29
Joined: Tue 09 Sep 2008 09:46

Postby Shalex » Thu 11 Sep 2008 13:49

We have performed investigations using large tables. As the result, the difference in performance between char(36) and raw(16) is unimportant.
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44

Postby Alladin » Tue 16 Sep 2008 15:20

The problem is not the performance (it could be almost the same), but that Oracle itself maps Guid data type to RAW(16) column type.

That means all existing & future software use and will use Guids as RAW(16). No DBA will change RAW(16) to CHAR(36) just because CoreLab is unhappy to implement it :)

The idea of Entity framework is to embrace existing databases to allow developers engage their OOP skills without touching database structure. That means - Guid = RAW(16) by default...

BTW, Guid type could be used as a primary key in EF & L2MSSQL without any problems.

http://blogs.msdn.com/dsimmons/pages/ef ... Section_17

What's a problem with Oracle?
Alladin
 
Posts: 149
Joined: Mon 27 Nov 2006 16:18

Postby huanghexd » Wed 17 Sep 2008 17:43

I tried Shalex's suggestion by using






For query it works fine. But after I made some changes to the returned objects and called SaveChanges(), it throwed an optimisitics concurrency exception. With DBMonitor, I found the reason is: Guids are sent to Oracle in the "-" seperated format while in the database it is saved as no "-" strings. So it can not find the object just returned during updating.

Any thought? Thanks.
huanghexd
 
Posts: 8
Joined: Tue 09 Sep 2008 19:06

Postby Shalex » Thu 18 Sep 2008 13:41

You have convinced us.
Unfortunately, text and binary guids cannot have complete support simultaneously. Entity Framework guids for OraDirect .NET will be binary (RAW(16)) starting from the next build.
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44

Postby Shalex » Mon 29 Sep 2008 13:36

The new build of OraDirect .NET version 4.75.43 is available!
Please visit http://www.devart.com/forums/viewtopic.php?t=12982
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44

Postby Shalex » Fri 03 Oct 2008 13:32

We recommend to wait for the next build to those who are interested in binary GUID. The current build has problems with saving it to a database.
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44

Postby Varun » Thu 13 Nov 2008 20:34

Is binary Guid issue fixed in OraDirect.NET 5 Beta
Varun
 
Posts: 6
Joined: Thu 13 Nov 2008 15:14

Postby Shalex » Fri 14 Nov 2008 14:22

The binary Guid issue is fixed in dotConnect for Oracle 5.00.
Shalex
Devart Team
 
Posts: 7608
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle