How to substitute an eSpace’s entity physical table name (table in db server)

How to substitute an eSpace’s entity physical table name (table in db server)

When you define an entity in Service Studio, say “Course”, and publish the eSpace, the platform will do all the DDL (data definition language) work for you.

It will create/change the database table, columns, primary key and indexes automatically. When possible, it will even change column types, in case you have changed them in Service Studio.

However, in current version (Hub Edition 2.0) you have no control over the physical table name given by the platform. So, you might end up with a table named ‘osusr_50_Course’ in sql server. The actual name depends on the eSpace id (50 in this example) and on other entity names defined on the eSpace.

If you want to change this physical name (either because you want a more legible name, a name independent from the eSpace id, or some other reason), you’ll have to change the data in one Hub Edition run time table. Then, recompile the eSpaces that are affected (the entity owner eSpace and all other eSpaces that use this entity through shared entities mechanism, if any) in order to have this changes take effect.

Please keep in mind that you are dealing with platform internal information. Be careful with the changes you make there, as your applications might become unusable if you change the wrong entities.

Here are the steps you should follow:
1. Open Sql Server Analyzer or Enterprise Manager
2. Select the Out Systems database
3. In ossys_Espace table, locate the row that that has column [Name] equal to your eSpace name. Get the Id number, let’s call it <ES_ID>.
4. In ossys_Entity table, locate the row that has column [Espace_Id] equal <ES_ID> and also column [Name] equal to your entity name in Service Studio.
5. Change the column [Physical_Table_Name] value to your desired name.

Now, when you recompile the eSpace owner, it will synchronize the sql server table with the eSpace entity. It means, for example, that it will create the table for you, if you haven’t done yet. The eSpace will also reference the new defined table.

After you recompile the other eSpaces that use this entity, they will also reference the correct table.