There is no Int32-Generator table in DO 4.6. We have no problem with recreate db.

But when we try to do PerformSafely, it says "schema has unsafe actions", so we do Perform.

After that key generator start keys from 1 for new entites!

So database is broken, because there are key duplicates.

How it can be solved?

This behavior makes impossible moving old project to DO 4.6.

asked Nov 01 '12 at 12:55

Ness's gravatar image

Ness
155232328


One Answer:

Hello Ness,

this might happen if you use SQL Server 2012.

DataObjects.Net 4.6 utilizes its new features such a native sequences.

There are two possible solutions:

Add ForcedServerVersion property with value 10.50.1600.1 in your DomainConfiguration. This forces usage of features available in SQL Server 2008 R2 only.

Manually replace Int32-Generator table with sequence:

-- Figure out current state of key generator table: current value and increment
select ident_current('Int32-Generator'), ident_incr('Int32-Generator')

-- Drop it to avoid name collisions
drop table [Int32-Generator]

-- Create sequence
create sequence [Int32-Generator]
   start with <current+increment>
   increment by <increment>

Unfortunately create sequence statement does not allow parameters for start with and increment by expressions. You'll have to cook constants using the above pseudo-code as example.

DataObjects.Net 4.6 provides new OnPrepare() method in upgrade handlers. This could be used to perform such modifications of the database schema before DataObjects.Net starts upgrade.

answered Nov 01 '12 at 13:24

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Yes, we use Sql Server 2012. We'll try second approach with replacing int32-generator.

Many thanks for the quick answer :)

(Nov 01 '12 at 14:29) Ness Ness's gravatar image

It works. Thanks.

By the way, when can we expect a post with a description of all the new features of DO 4.6? :)

(Nov 01 '12 at 14:35) Ness Ness's gravatar image

There is blog post that covers major improvements in general: http://blog.dataobjects.net/2012/10/dataobjectsnet-46-goes-final.html Also there is introductory post about advanced mapping: http://blog.dataobjects.net/2012/10/advanced-mapping-in-dataobjectsnet-46.html There are plenty of small improvements that are not covered unfortunately. We'll keep blogging about interesting stuff as time constraints allow.

(Nov 01 '12 at 14:57) Denis Krjuchkov Denis%20Krjuchkov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

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

Tags:

×12
×2

Asked: Nov 01 '12 at 12:55

Seen: 2,883 times

Last updated: Nov 01 '12 at 14:57

powered by OSQA