raxuser100 wrote:
Thanks David and Frans.
I will most likely just rename the tables manually which should be retained after future syncs with the Db.
Would you happen to have a sample C# plugin that I could use to automate and add some custom logic please?
Look forward to v5.7!
If it's a one-time thing, you can use the element search in the designer. It allows you to run any C# against the entity model.
Open element search, select 'Entity' as element type and paste the following (I use SQL Server here, the driver id of your db is in the first code pane, so you have to adjust it for that)
var cmd = new UndoablePeriodCommand("Renaming elements");
CommandQueueManagerSingleton.GetInstance().BeginUndoablePeriod(cmd);
foreach(EntityDefinition e in p.EntityModel.Vertices)
{
var mapping = p.GetGroupableModelElementMapping(e, SqlServerSqlClientDriverID, false);
if(mapping==null || mapping.MappedTarget==null)
{
continue;
}
e.Name = string.Format("{0}{1}", mapping.MappedTarget.ContainingSchema.SchemaOwner, e.Name);
}
CommandQueueManagerSingleton.GetInstance().EndUndoablePeriod(cmd);
return p.EntityModel.Vertices;
This will prefix all names in the entity model with the schema name.
You can limit the elements you want with filtering p.EntityModel.Vertices (which are all entities in the model) based on a subset, e.g. a list of names you hardcode, e.g. to avoid having all names prefixed and only the ones you need which are duplicates (like your User example).
It also has undo / redo awareness, so you can undo the action in one go. It might appear a bit slow, that's caused by the fact that you're renaming elements one by one and the UI will get notified by that and will re-render the element in the project explorer...
Renaming the tables is best done in the database itself, as some databases require to drop/recreate renamed tables so the provided tooling for the database can help there. Then you can simply sync your project in the designer with the database and the designer should pick up renamed elements (it will do heuristics for renamed elements).
If you want to write a plugin, you can look at the sourcecode archive on the website which comes with the sourcecode of a couple of plugins, and the SDK:
https://www.llblgen.com/Documentation/5.6/SDK/gui_implementingplugin.htm