Why do ionic compounds like NaCl conduct electricity when dissolved but not when they’re solid, whereas metals conduct electricity when they’re solid?

A Level