Entity Framework and System.Guid
Entity Framework and System.Guid
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
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
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.
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.
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
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
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?
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?
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.
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.
The new build of OraDirect .NET version 4.75.43 is available!
Please visit http://www.devart.com/forums/viewtopic.php?t=12982
Please visit http://www.devart.com/forums/viewtopic.php?t=12982