A question about Dedekind schemes and proper morphisms The following is Exercise 15.3 of Görtz-Wedhorn Algebraic Geometry I:

Let $S$ be a Dedekind scheme with function field $K$ and let $f: X\to S$ be a proper morphism of schemes. Then the canonical map $X(S)\to X(K)$ is a bijection.

For example, the map $X(S)\to X(K)$ being injective means ${\rm Spec}\ K\to S$ is an epimorphism of schemes. I'm no idea to prove it, even for $S$ affine. For subjectivity, I can only see (using valuation criterion for being proper) that a morphism ${\rm Spec}\ K\to X$ extends to a morphism ${\rm Spec}\ \mathscr{O}_{S, y}\to X$ ($y$ being the image of ${\rm Spec}\ K\to X\to S$ but don't know how to extends to the whole of $S$.
I'm also wondering if the maps need to respect morphisms to $S$, namely if we need to consider $X_S(S)\to X_S(K)$ instead of $X(S)\to X(K)$.
 A: Injectivity is because $X$ is separated. The locus where two morphisms $S \to X$ agree is a closed subscheme and if it contains the generic point, it's everything.
For surjectivity, we can "spread out" the morphism $Spec K \to X$ to a morphism $U \to X$ from an open subset $U \subset S$ and then use the valuative criterion to fill in the finitely many missing point.
Edit: Here are some more details. So spreading it out is the general procedure where if we have an integral ring $R$ with fraction field $K$, a finite type scheme $X$ and a $K$ point of $X$, we can extend it to a $R_{f}$ point because there will only be finitely many denominators. For an easy example, suppose $X = \mathbb A^1$ and $R = \mathbb Z$ and the rational point is $t \to 1/2$. Then, there is an obvious way to think of this as a $\mathbb Z[1/2]$ point.
So given a rational point of $X$, we can extend this to a map from an open subset $U \subset S$ to $X$. Since $S$ is a Dedekind scheme, there are finitely many height one primes in the complement of $U$. Consider the local ring $R_{\mathfrak p}$ at one of these primes which is a DVR.
By the valuative criterion, we can get a $R_{\mathfrak p}$ point of $X$. Again, by spreading out, we can extend this to a map from $V \to X$ for $V$ another open subset of $S$ that contains $\mathfrak p$. On the other hand, the maps from $V \to X$ and $U\to X$ match on their intersection (by the same argument as for injectivity) and so we can extend this to a map $U\cup V \to X$.
Repeating this process for any points still left over, we get a map $S \to X$ that extends our rational map.
