Hi
I generating a test model via TMS Data Modeler of a many to many situation (2 parents and one child). In the database there is a referential integrity relation with cascading deletes between parents and child.
But because I want to work via Code First I copied the generated code into Delphi:
[Entity]
[Table('AppMemberCategory')]
[Id('FCategoryId', TIdGenerator.None)]
[Id('FAppMemberId', TIdGenerator.None)]
TCategoriesInMember = class
private
[Association([TAssociationProp.Lazy, TAssociationProp.Required],
CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('AppMemberId', [TColumnProp.Required], 'ID')]
FAppMemberId: Proxy<TAppMember>;
[Association([TAssociationProp.Lazy, TAssociationProp.Required],
CascadeTypeAll - [TCascadeType.Remove])]
[JoinColumn('CategoryId', [TColumnProp.Required], 'ID')]
FCategoryId: Proxy<TCategory>;
function GetAppMemberId: TAppMember;
procedure SetAppMemberId(const Value: TAppMember);
function GetCategoryId: TCategory;
procedure SetCategoryId(const Value: TCategory);
public
property AppMemberId: TAppMember read GetAppMemberId write SetAppMemberId;
property CategoryId: TCategory read GetCategoryId write SetCategoryId;
end;
When I fire up the application the table and relations are generated but WITHOUT the cascading delete setting in the relations! It does not do a 360.
How can I set this cascading deletes up ?
Thanks, Edward
// Generated SQL
AppControl: CREATE TABLE AppMemberCategory (
AppMemberId INT NOT NULL,
CategoryId INT NOT NULL,
CONSTRAINT PK_AppMemberCategory PRIMARY KEY (CategoryId, AppMemberId))
---------------
AppControl: ALTER TABLE AppMemberCategory ADD CONSTRAINT
FK_AppMemberCategory_Categories_CategoryId FOREIGN KEY (CategoryId) REFERENCES Categories (ID)
---------------
AppControl: ALTER TABLE AppMemberCategory ADD CONSTRAINT
FK_AppMemberCategory_AppMembers_AppMemberId FOREIGN KEY (AppMemberId) REFERENCES AppMembers (ID)
---------------