I wrote a similar solution which you can find on GitHub (geokml). It has no references to any library except the SQL Server-libraries.
The library provides attributes so you can turn any entity framework-entity into kml. The unittest-project gives also information how to do that.
I would happy to help you with this.
when you like to use it I can even publish it on NuGet.