Author Topic: changing database through an add in  (Read 2564 times)

ado

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
changing database through an add in
« on: May 05, 2008, 06:21:21 pm »
I create a database modell for sql server 2005. When I change the database in EA to e.g. Oracle the column types also change from e.g. datetime to date. Now I try to do this via an add in. I loop through the repository and call element.GenType = "Oracle" for each element and after this element.Update(). The database changes but the not the column types. What is missing here ?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: changing database through an add in
« Reply #1 on: May 05, 2008, 09:52:58 pm »
I suspect - entirely without proof - that when you do this from the UI EA is 'helping' you in the background. EA would be able to 'realize' that you'd made a change and do the necessary background work before returning control to the UI.

There are several other situations where this is true. A simple example is setting up a new diagram. EA looks at various settings - things like whether to display diagram notes - and tweaks the new diagram to reflect these settings, all before it displays the diagram to you for the first time. If you are using the API to create the diagram though, you have to look up these settings - or use the current default from your automation application - and set them yourself. Otherwise you will end up with diagram notes displayed (for example) regardless of the current EA option settings.

There are similar situations in how elements are created and handled, and in other places throughout EA.

If you are doing this from the API you are in charge. Sparx makes no assumptions regarding how you want to update your tables - or even if you want to do so - and leaves the decision to you. After all, perhaps the very reason you are writing the add-in is to modify the default behavior of the application, and this is the one thing you want to control...

So the bottom line is you can have it any way you want, if you are willing to do the work yourself. When you think about it a bit, that's the best way in the long run.

David
No, you can't have it!