When a person has contracted to perform an obligation at a particular place, and resides in another county, the action must be commenced, and, subject to the power of the court to change the place of trial as provided in this chapter, must be tried in the county in which such obligation is to be performed or in which the person resides; and the county in which the obligation is incurred shall be deemed to be the county in which it is to be performed, unless there is a special contract to the contrary.
Actions for the following causes shall be tried in the county in which the subject of the action, or some part thereof, is situated, subject to the power of the court to change the place of trial as provided in this chapter:
For the recovery of real property, or an estate, or interest therein, or for the determination in any form of such right or interest, and for injuries to real property.
For the partition of real property.
For the foreclosure of all liens and mortgages on real property. Where the real property is situated partly in one county and partly in another the plaintiff may select either of the counties, and the county so selected is the proper county for the trial of such action; but, in the case mentioned in this paragraph, if the plaintiff prays in the complaint for an injunction pending the action, or applies pending the action for an injunction, the proper county for the trial shall be the county in which the defendant resides or a majority of the defendants reside at the commencement of the action.