Hello,

as stated in the title i'm using Entity Framework 4.1 to connect to a SA 12 database. Some of the entities in my EDM have properties where the values are generated by the database (using insert/update triggers). EF supports that by setting the StoreGeneratedPattern attribute to the corresponding properties of the entities. There are 2 values (beside None = no database generated values): Identity (which means the value is generated after an insert) and Computed (which means the value is generated after inserts and updates). I use both kinds.

I set these attributes a while ago without (unfortunately) thoroughly testing if it worked correctly, because by the first look it seemed to work perfectly.

But now on a second look i see that newly inserted entities do not display the correct values immediately after the SaveChanges call on the DbContext. After reloading the entity the correct database generated values are displayed (which means the actual trigger logic works).

I use the Entity Profiler to analyze the queries/commands the EF generates, and took a closer look at the insert statement. After the actual insert statement there is a select statement which tries to get the database generated values for the corresponding columns, that looks like the following:

   select [SOME_GENERATED_NO],  -- StoreGeneratedPattern: Identity
       [CREATED_AT],             -- StoreGeneratedPattern: Identity
       [CREATED_BY],             -- StoreGeneratedPattern: Identity
       [CHANGED_AT],             -- StoreGeneratedPattern: Computed
       [CHANGED_BY]              -- StoreGeneratedPattern: Computed
   from   [MY_TABLE]
   where  @@ROWCOUNT > 0

The problem here is, that there is no filter for the new ID (primary key) of the inserted row (the ID is set by my allication before saving). So the result set contains all rows of MY_TABLE that exists (although Entity Profiler reports a row count of only 1). But i always get the store-generated values of the first row of MY_TABLE (which of course is not the newly inserted).

Is this a known problem with the current version of the SA Data Provider for EF or could i have overlooked some other detail (maybe a configuration in the EDM)?

Another problem that i encountered is that for some other entities that have store-generated value columns there is no select statement to retrieve generated values after inserts/updates at all.

Thanks for any help on this topic.

Update:

  1. The time I encountered this issue the first time, I was using version 12.0.1.3152
  2. The problem is still present in the current version (12.0.1.3852)

asked 05 Apr '12, 04:27

Andre%20Hentschel's gravatar image

Andre Hentschel
1767715
accept rate: 0%

edited 21 Mar '13, 13:52

Just another very wild guess: May it be the "Key property" is missing for the PK column?

(05 Apr '12, 04:52) Volker Barth

Key properties are all there (i suppose the model validation would cause errors if it wasn't so).

(05 Apr '12, 05:06) Andre Hentschel

Thanks for pointing out the problem. The bug is fixed in 12.0.1.3719 (or any later update) which may become available soon. EBF number is 704978.

permanent link

answered 13 Apr '12, 14:40

JBSchueler's gravatar image

JBSchueler
2.0k2836
accept rate: 16%

I just realized, that this bug is still present in the current EBF (12.0.1.3851). After further investigation I found that the case I added to Sybase Case-Express was closed on January 3rd with a statement, that the description of the issue wasn't enough to base an investigation on.

It is also stated, that I should buy a regular support case, if that problem is a "current issue". I will not do this, since I already implemented a workaround at the time I wrote the initial question, and I just wanted to make people, who care, aware of this problem by asking this question and adding a (not-paid-for) case in Case-Express.

Although this question is now about an year old, I hope you might clarify why this wasn't fixed in the end.

Was it maybe an issue that has its cause not in the Sybase Data Provider, but in the MS part of the Entity Framework? Or was this simply forgotten?

If it helps: the Case ID in Case-Express is 11730316

(21 Mar '13, 12:01) Andre Hentschel
Replies hidden

I have now reviewed these case notes.

In the Case-Express closing notes, it was recommended to you that you should additionally investigate Microsoft KB #2561001, which is potentially affecting your results. (So yes, this may actually be a problem in the EF itself). Since the "submit a bug" service is a non-interactive service, it was never clarified if applying this Microsoft KB actually resolves the issue for you.

Furthermore, the case notes for #11730316 do not list a specific SQL Anywhere version/build that you specifically tried - it only lists the versions of the entity frameworks - therefore it wasn't clear if you had applied CR #704978 or not.

If you think this is still an error after checking this Microsoft bug (and verify the version you're running with now - I assume 12.0.1.3851), you should re-file your bug submission with us, detailing these updated steps that you have tried, and reference the previous case.

(21 Mar '13, 12:14) Jeff Albion
Comment Text Removed

Thanks for the quick answer. I will submit a new bug then (if the Microsoft KB isn't the fix). I'm still wondering why a bugfix in such a specific EBF was announced in the original answer ... must have been a mix-up

(21 Mar '13, 13:05) Andre Hentschel

(Note: Thas was converted from a question comment...)

Then I don't have a clue. Are you testing with the newest 12.0.1 EBF?

EDIT: As you are not, it seems worth trying a new one...and see if that has an effect...

permanent link

answered 05 Apr '12, 05:13

Volker%20Barth's gravatar image

Volker Barth
29.6k293444650
accept rate: 32%

edited 05 Apr '12, 07:10

What exactly does EBF mean? Is it the ADO.NET data provider of SA? then i think i'm working with the current version (which is installed alongside the developer edition of SA 12). How can i determin which version i use?

(05 Apr '12, 05:22) Andre Hentschel
Replies hidden
1

Run "select @@version" against the database server. EBF is an "Emergency Bug Fix", somewhat comparable to a MS service pack (though offered more frequently and more focussed on bug fixes and not necessarily on new functionality). FWIW, "bigger enhancements" are contained in MRs ("Maintenance Releases") like 12.0.1 which updates 12.0.0.

Confine Breck Carter's list of current EBFs which also links to the EBF Download page.

(05 Apr '12, 05:33) Volker Barth

Thanks for the info. I am actually not using the latest version (it is 12.0.0.2483). I will update to the latest version to see, if the problem still remains. I did not find an upgrade to 12.0.1, i assume i have to download and install the 12.0.1 dev-version, and can not upgrade my installed 12.0.0?

(05 Apr '12, 06:47) Andre Hentschel

So you are using the original 12.0.0 GA version from mid 2010. That's somewhat similar to using a new Windows Version without any Windows updates/service packs...(well, say, without the security implications...).

As you are using new tools like EF, I would strongly suggest to use a fresh EBF. The MR itself can be found on the Download page but you will have to adapt the "Display" property on the page top to "in ALL MONTHS".

The Windows 12.0.1 MR is from Feb 2011. You can install that, and then install a current EBF (possibly the newest one or one of the previous ones...). EBFs are cumulative, so installing 12.0.1.3605 will include all fixes from 12.0.1 MR up to that one.

(05 Apr '12, 07:02) Volker Barth
(05 Apr '12, 07:06) Volker Barth

Just to wrap the SA version topic up: I installed a newer version (12.0.1.3519, which is admittedly not the latest available, but the latest that is supported by the company i work for). But the problem persists.

I also set up a minimalistic test EDM to make sure that the problem is not caused by any of the modifications i made to my EDM (the one for the product i develope) and its partial entity classes, and also for the test project there is no WHERE clause generated uses the ID of the inserted/updated row for filtering (there is only the "WHERE @@ROWCOUNT > 0").

So as of now i consider this behavior a bug (which is somehow hard to believe for since i think the store generated pattern feature is an important one that would be used by many developers).

(05 Apr '12, 10:10) Andre Hentschel
showing 2 of 6 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×406
×88
×65

question asked: 05 Apr '12, 04:27

question was seen: 2,587 times

last updated: 21 Mar '13, 13:52