Apex Trigger
trigger AccountTrigger on Account (before delete) {
List<Contact> relatedContacts =[SELECT AccountId FROM Contact WHERE AccountId IN: Trigger.oldMap.keySet()];
for(Contact con : relatedContacts){
Trigger.oldMap.get(con.AccountId).addError('You can not delete an Account with a Contact');
}
}