How do I make bullets damage enemies in a top down shooter?

We are making a top down shooter in 2d and nothing we try to make the bullets do damage works.

This is our current code for the bullet it is currently not detecting when it hits an enemy:

public class Bullet : MonoBehaviour
{

public GameObject hitEffect;



private void OnCollisionEnter2D(Collision2D collision)
{
    GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity);
    Destroy(effect, 2f);
    Destroy(gameObject);

}

private void Update()
{
    RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, transform.up, distance, whatIsSolid);
    if (hitInfo.collider != null)
    {
        if (hitInfo.collider.CompareTag("Enemy"))
        {
            Debug.Log("Hit");
        }
    }
}

}

Is on collision enter being entered at all? if not u may need a Rigidbody2D I believe on collision enter doesnt work if there is no RB