Book a Demo

Author Topic: Creating Primary keys with automation  (Read 4039 times)

Daleb

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Creating Primary keys with automation
« on: April 04, 2005, 07:14:51 pm »
Does anyone have an example of creating a primary key through the automation interface?
I can create a primary key operation that looks fine in EA, but I can't seem to get the key columns to appear, or get marked as a PK in the column list.

Here is what I've got so far -

       // add a primary key (for some reason EA calls this an operation/method)
       method = (EA.Method) table.Methods.AddNew("PrimaryKey", "PK");
       method.Stereotype = "PK";

       foreach(EA.Attribute column in table.Attributes)
       {
         if (column.Stereotype.Equals("PK"))
         {
           parameter = (EA.Parameter) method.Parameters.AddNew(column.Name, "Parameter");
           parameter.Kind = "in";
           parameter.Type = "int";

           parameter.Update();
         }
         method.Parameters.Refresh();
         method.Update();
       }
       table.Methods.Refresh();
       table.Update();

charge

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Creating Primary keys with automation
« Reply #1 on: April 27, 2005, 06:53:00 am »
You have to do more than this... I have it working now