DCSIMG
Migrating Entity Framework’s EDM from Sql Server to Oracle - Ido Flatow's Blog Veni Vidi Scripsi

Ido Flatow's Blog

Veni Vidi Scripsi

News

Have you heard me speak?
Powered
<style type='text/css' media='screen' id='sm_css'> #smix {overflow: visible;height: auto;border-radius: 10px;max-width: 250px;background-color: #323232;text-align: left;font-size: 12px;line-height: 16px;font-family:'Lucida Sans Unicode','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;} #smix a {color: #0056CC;text-decoration: none;} #smix .sm_head {color: #fff; line-height: 1em;font-size: 1.4em;padding: 10px;color: #fff;} #smix .sm_lanyard_wrapper {background-color: #fff;;clear: both;width: 97%;margin: 0 auto;margin-bottom: 0px;} #smix .sm_lanyard_content {padding: 7px;}#smix button.sm_rec, #smix a.sm_rec, #smix input[type=submit].sm_rec { padding: 6px 10px; -webkit-border-radius: 2px 2px;-moz-border-radius: 2px; border-radius: 2px; border: solid 1px rgb(153, 153, 153); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221))); color: #333; text-decoration: none; cursor: pointer; display: inline-block; text-align: center; text-shadow: 0px 1px 1px rgba(255,255,255,1); line-height: 1; }#smix .sm_rec:hover { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(248, 248, 248)), to(rgb(221, 221, 221))); }#smix .sm_rec:active { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(204, 204, 204)), to(rgb(221, 221, 221))); }#smix .sm_rec.medium { padding: 3px 7px; font-size: 13px; }#smix .sm_rec span.icon.thumbs_up {background-position: 0px 36px;vertical-align: text-top;display: inline-block;margin-right: 4px;height: 18px;width: 16px;background-image: url(http://speakermix.com/images/new/thumbsold.png);}#smix .sm_rec:hover span.icon.thumbs_up {background-position: 0px 18px;} #smix .sm_events {padding:2px 0px 4px 0px;} #smix .sm_section {font-size: 10px; border-bottom: 1px solid silver; margin-bottom: 6px;} #smix .sm_subline {font-size:120%;margin-top:4px;font-weight:bold} #smix .powered {text-align: right} #smix .powered img {margin: 7px} </style>
Sela Technology Center

Advertisement

Migrating Entity Framework’s EDM from Sql Server to Oracle

A few weeks ago I've published a post regarding DataDirect's new Oracle provider that supports EF.

I was able to download DataDirect’s provider only this week, so it will take me a few more days to examine it and post some notes.

As for now, I would like to share with you some of the issues in EF we’ve came across migrating from Sql Server to Oracle, using the provider from DevArt.

BTW, we haven’t fully migrated to Oracle just yet, our project supports working with both databases using a factory for the creation of the EDM and the ObjectContext’s connection.

If you use EF at its simplest form, creating entity types and mapping them to tables, you won’t have many problems, the actual problems begins when you use the more extensive options EF has to offer, including user defined queries, using stored procedures etc..

Type matching

Different DBs have different types, the following table will help you decide which types to give your columns in your new Oracle tables.

LOB problems

If you use Oracle’s LOB types (BLOB, CLOB…) you will have a problem doing Union/Minus/Intersect queries, so if you have LOB columns in your entity and you currently use Linq to Entities queries with Union/Except/Intersect calls, you’ll need to restructure your queries.

Writing your own queries

If you decide to write your own sql select statement (using DefiningQuery), you will notice a bug that exists in Devart’s provider – If you write a sql statement like this:

Select column1, column2 from …

The generated sql statement that will be executed in the DB will look like this:

Select "extent1"."column1", "extent1"."column2" from (...) "extent1"

Since in oracle there is a difference between selecting “column1” and column1, your query will raise an error. To solve this problem, you just do the following fix to your sql statement:

Select column1 as “column1”, column2 as “column2” from …

I assume this bug will be fixed in next versions of the provider and I didn’t had the chance to see how DataDirect’s provider works, but I have the feeling they don’t have this problem (I hope I won’t be surprised).

Returning Keys and ResultBinding from Stored Procedures

When we write our own Stored Procedures for CUD operations, we sometimes have to deal returning auto-generated keys and computed values.

In Sql Server this is easy, we use the Select statement and select the values we want to return from the SP, and in the EF’s mapping we use ResultBinding to specify how to copy these values to their target properties.

In Oracle things get a bit tricky – you cannot write Select statements inside a SP without directing them to variables, so your SP needs to have an Out parameter of REF CURSOR type and use this parameter to hold the new values you want to return.

You’ll need to add this parameter to your Function element:

<Parameter Name="VCUR" Type="REF CURSOR" Mode="In" />

(There’s a bug with the Mode enumeration, so you can’t use Out)

And add a ResultBinding to your ModificationFunctionMapping:

<ResultBinding Name="DEPTNO" ColumnName="NEW_DEPTNO" />

This sounds easy enough, but with EF there is a small problem – if you add a parameter to your SP, you also have to map it to a property in your conceptual model, so we find ourselves forced to create a “dummy” property to hold the return value of the SP.

The EDM will look something like this (taken from example given by Devart’s support team with some changes):

<!-- SSDL content -->
...
        <EntityContainer Name="ModelStoreContainer">
          <EntitySet Name="DEPT" EntityType="Model.Store.DEPT">
            <DefiningQuery>select …, to_blob(null) as “Column1” from dept</DefiningQuery>
          </EntitySet>
        </EntityContainer>
        <EntityType Name="DEPT">
          <Key>
            <PropertyRef Name="DEPTNO" />
          </Key>
          <Property Name="DEPTNO" Type="int" Nullable="false" />
          <Property Name="DNAME" Type="VARCHAR2" MaxLength="14" />
          <Property Name="LOC" Type="VARCHAR2" MaxLength="13" />
          <Property Name="COLUMN1" Type="BLOB" MaxLength="1" />
        </EntityType>
...
<!-- CSDL content -->
...
        <EntityType Name="DEPT">
          <Key>
            <PropertyRef Name="DEPTNO" />
          </Key>
          <Property Name="DEPTNO" Type="Int32" Nullable="false" />
          <Property Name="DNAME" Type="String" MaxLength="14" Unicode="true" FixedLength="false" />
          <Property Name="LOC" Type="String" MaxLength="13" Unicode="true" FixedLength="false" />
          <Property Name="COLUMN1" Type="Binary" MaxLength="1" />
        </EntityType>
...
<!-- C-S mapping content -->
...
<EntityTypeMapping TypeName="IsTypeOf(Model.DEPT)">
              <MappingFragment StoreEntitySet="DEPT">
                <ScalarProperty Name="DEPTNO" ColumnName="DEPTNO" />
                <ScalarProperty Name="DNAME" ColumnName="DNAME" />
                <ScalarProperty Name="LOC" ColumnName="LOC" />
                <ScalarProperty Name="COLUMN1" ColumnName="COLUMN1"/>
              </MappingFragment>
</EntityTypeMapping>
...

Of course, once you do the above you’ll have a Blob column in your Select statement and you’ll have the LOB problem I’ve discussed previously.

The SP problem was one of our pitfalls migrating to Oracle, and as I understand, Devart will probably fix this in future versions, I just hope DataDirect’s provider doesn’t suffer from the same problem.

These where some problems we’ve faced migrating to Oracle. There are of course other issues such as rewriting SP, renaming SP parameters due to differences of naming conventions and other problems you face in these cases regardless of EF.

I will check DataDirect’s provider and will publish some notes in the future.

Comments

Jonathan Bruce said:

Looking forward to your posting our support for ADO.NET Entity Framework for Oracle.

Otherwise, moving EF applications between SQL Server and Oracle, we gained a lot of experience while building our tests suites, and in fact we have built in features that ease that migratio

# June 23, 2009 10:28 PM

Chaitanya Deshpande said:

Do you have any updates after you tried the provider from DataDirect? Thanks!

# December 7, 2009 8:15 AM

Chaitanya Deshpande said:

Any updates after you tried the provider from dataDirect?

Thanks!

# December 7, 2009 8:17 AM

Kelis said:

A good many valuaebls you've given me.

# December 10, 2011 10:30 AM

Zielinski said:

I read this post fully concerning the resemblance of latest and

previous technologies, it's remarkable article.

# August 1, 2012 2:26 PM

Weatherly said:

I'm really enjoying the design and layout of your website. It's a

very easy on the eyes which makes it much more pleasant for me

to come here and visit more often. Did you hire out a

designer to create your theme? Great work!

# August 4, 2012 11:57 AM

Sanborn said:

Hmm is anyone else having problems with the images on this blog loading?

I'm trying to find out if its a problem on my end or if it's the blog.

Any feed-back would be greatly appreciated.

# September 11, 2012 6:03 AM

Neill said:

Sex femme 18

# September 17, 2012 1:09 AM

Messina said:

Buzz sex long porno tubes

# October 5, 2012 12:23 AM

Bailey said:

Vielle video porno grosse ejaculation buccale

# October 8, 2012 5:53 AM

Gann said:

Dna horoscope 2011 mlle lenormand tirage gratuit

# October 16, 2012 5:03 PM

Soares said:

Can you tell us more about this? I'd want to find out some additional information.

# November 8, 2012 1:05 PM

Blackwell said:

President 2012 voyance oracle gratuit des anges

# November 11, 2012 10:14 AM

Richey said:

For hottest information you have to visit world-wide-web and on internet I found this web site as a most excellent web page for hottest

updates.

# November 12, 2012 7:22 PM

Rico said:

Voyeur plage nudiste femme nue exhibition

# November 20, 2012 10:54 AM

Woodruff said:

Ridiculous story there. What happened after? Thanks!

# November 23, 2012 4:14 AM

Darnell said:

Video porno 100 gratuit contributions amateur

# December 10, 2012 11:20 PM

Ruth said:

U porn sex movie lesbienne gratuit streaming

# December 21, 2012 1:49 AM

Wallin said:

Le plus gros sexe du monde amateur grosse bite

# December 24, 2012 11:20 PM

Covey said:

Site de tarot gratuit astrologie yahoo gratuite

# December 27, 2012 6:23 PM

Montenegro said:

This is a topic which is close to my heart..

. Take care! Where are your contact details though?

# January 15, 2013 5:55 PM

Lombardo said:

Youporn 2010 video gratuite baise

# January 24, 2013 7:13 AM

Alderman said:

Video sex amateur gratuite pornos clips

# January 29, 2013 2:31 AM

Magnuson said:

Quel procedure pour divorcer guide du divorce

# February 12, 2013 11:07 AM

Simons said:

La vierge signe astrologique voyant medium gratuit

# February 14, 2013 6:58 AM

Samples said:

Contact contact voyance-web.fr cancer signe d

eau

# February 14, 2013 10:05 AM

Prosser said:

It's genuinely very complicated in this active life to listen news on Television, so I simply use the web for that purpose, and obtain the most up-to-date information. Suggested Looking at

# February 25, 2013 12:58 PM

Gooden said:

Hi there, everything is going well here and ofcourse every

one is sharing information, that's genuinely excellent, keep up writing. Full Survey

# February 25, 2013 7:48 PM

Inman said:

Hi, I would like to subscribe for this web site to get most up-to-date updates, so where can i do it please

assist. Justina

# February 26, 2013 10:31 AM

Kenny said:

Horoscope septembre capricorne jeu du tarot gratuit

# February 28, 2013 11:34 AM

Croft said:

Hey I know this is off topic but I was wondering if you knew of any widgets I

could add to my blog that automatically tweet my newest twitter updates.

I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates. our website

# March 4, 2013 1:27 PM

Crowder said:

Son jouissance beau cul beau sein

# March 4, 2013 7:03 PM

Heyward said:

It's going to be end of mine day, except before finish I am reading this enormous piece of writing to improve my experience.

# March 6, 2013 4:27 PM

Bartley said:

Quality articles or reviews is the crucial to be a

focus for the users to pay a quick visit the site, that's what this web page is providing. Recommended Internet site

# March 7, 2013 3:43 AM

Wilcox said:

Porno mapouka video charme porno

# March 8, 2013 6:13 AM

Mcgregor said:

Conseil divorce gratuit divorce lyon

# March 9, 2013 1:08 PM

Tucker said:

Procedure divorce residence alternee

# March 11, 2013 11:24 AM

Zapata said:

Porno xxx film gode amateur

# March 18, 2013 4:12 AM

Polanco said:

Manga porno xxx lizzie tucker anal

# March 18, 2013 4:18 AM

Wills said:

Hello everyone, it's my first pay a visit at this site, and article is genuinely fruitful for me, keep up posting these posts.

# March 18, 2013 10:16 AM

Drummond said:

Video sexi streaming amanda tapping sex

# April 4, 2013 3:04 PM

Lemke said:

Put spread camera cachee voyeur

# April 5, 2013 11:20 AM

Affizeevono said:

[url=www.imitrexonlineprice.net]imitrex for sale [/url] imitrex without prescription  - <a href=www.imitrexonlineprice.net>sumatriptan online no prescription </a> - imitrex online  www.imitrexonlineprice.net

# April 20, 2013 9:04 PM

UniseBoon said:

[url=http://www.klonopinonsale.net/]Klonopin No Prescription[/url] buy klonopin no prescription  - <a href=http://www.klonopinonsale.net/>Klonopin No Prescription</a> - klonopin price  http://www.klonopinonsale.net/

# April 21, 2013 8:32 AM

loafrorninfob said:

[url=www.imitrexonlineprice.net]buy generic imitrex online [/url] buy cheap imitrex  - <a href=www.imitrexonlineprice.net>order imitrex </a> - imitrex price  www.imitrexonlineprice.net

# April 21, 2013 10:25 AM

Tobin said:

This is a topic that's close to my heart... Best wishes! Where are your contact details though? Www.buildchickencoop.

# April 21, 2013 5:42 PM

Newberry said:

Valuable info. Lucky me I found your web site accidentally, and I'm shocked why this twist of fate did not took place earlier! I bookmarked it.

# April 22, 2013 2:42 PM

Tenney said:

Wikipedia actrice porno lesbien mature

# May 3, 2013 2:12 PM

Mark said:

Milf porno tube porno blackette

# May 3, 2013 3:25 PM

Mahoney said:

Sex toy canard amateurs baisent

# May 3, 2013 10:45 PM

Mcneill said:

Amateur sexe tube films porno amateurs gratuits

# May 4, 2013 12:39 AM

Tirado said:

Video ejaculation vaginale masturbation d hommes

# May 4, 2013 10:49 AM

Garza said:

Porno anus boite lesbienne paris

# May 4, 2013 11:21 AM

Santoro said:

Porno couple mature collant sexe

# May 4, 2013 1:41 PM

Carrillo said:

I pay a quick visit each day some blogs and sites to read articles or reviews, except this blog gives feature based articles.

# May 7, 2013 7:22 AM

aixwbele@gmail.com said:

Thanks a lot for your post. I'd really like to comment that the price of car insurance differs from one plan to another, due to the fact there are so many different facets which contribute to the overall cost. Such as, the make and model of the car or truck will have an enormous bearing on the purchase price. A reliable old family auto will have a more affordable premium when compared to a flashy sports car.

# May 8, 2013 11:53 PM

Cline said:

Test masturbateur homme dial sex

# May 15, 2013 10:53 PM

Duggan said:

Tirage cartes marie claire ephemerides astrologiques

# May 16, 2013 3:08 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: