diff --git a/Database/Persist/TH.hs b/Database/Persist/TH.hs
--- a/Database/Persist/TH.hs
+++ b/Database/Persist/TH.hs
@@ -41,7 +41,7 @@
 
 import Prelude hiding ((++), take, concat, splitAt, exp)
 import Database.Persist
-import Database.Persist.Sql (Migration, migrate, SqlBackend, PersistFieldSql)
+import Database.Persist.Sql (Migration, migrate, SqlBackend, PersistFieldSql, IsSqlKey (..))
 import Database.Persist.Quasi
 import Language.Haskell.TH.Lib (varE)
 import Language.Haskell.TH.Quote
@@ -53,7 +53,7 @@
 import Data.Text.Encoding (decodeUtf8)
 import qualified Data.Text.IO as TIO
 import Data.List (foldl')
-import Data.Maybe (isJust, listToMaybe, mapMaybe, fromMaybe)
+import Data.Maybe (isJust, listToMaybe, mapMaybe, fromMaybe, isNothing)
 import Data.Monoid (mappend, mconcat)
 import Text.Read (readPrec, lexP, step, prec, parens, Lexeme(Ident))
 import qualified Data.Map as M
@@ -631,7 +631,13 @@
         else if not useNewtype
                then do pfDec <- pfInstD
                        return (pfDec, [''Show, ''Read, ''Eq, ''Ord, ''Generic])
-                else return ([], [''Show, ''Read, ''Eq, ''Ord, ''PathPiece, ''PersistField, ''PersistFieldSql, ''ToJSON, ''FromJSON])
+                else do
+                    let addIsSqlKey
+                            | mpsBackend mps == ConT ''SqlBackend &&
+                              isNothing (entityPrimary t) =
+                                (''IsSqlKey :)
+                            | otherwise = id
+                    return ([], addIsSqlKey [''Show, ''Read, ''Eq, ''Ord, ''PathPiece, ''PersistField, ''PersistFieldSql, ''ToJSON, ''FromJSON])
 
     let kd = if useNewtype
                then NewtypeInstD [] k [recordType] dec i
@@ -691,6 +697,10 @@
               toJSON = toJSON . $(return $ VarE $ unKeyName t)
            instance FromJSON (BackendKey $(pure backendT)) => FromJSON (Key $(pure recordType)) where
               parseJSON = fmap $(return $ ConE $ keyConName t) . parseJSON
+
+           instance IsSqlKey (BackendKey $(pure backendT)) => IsSqlKey (Key $(pure recordType)) where
+              toSqlKey = $(return $ ConE $ keyConName t) . toSqlKey
+              fromSqlKey = fromSqlKey . $(return $ VarE $ unKeyName t)
         |]
 
     useNewtype = length keyFields < 2
diff --git a/persistent-template.cabal b/persistent-template.cabal
--- a/persistent-template.cabal
+++ b/persistent-template.cabal
@@ -1,5 +1,5 @@
 name:            persistent-template
-version:         2.0.1.1
+version:         2.0.2
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <michael@snoyman.com>
@@ -17,7 +17,7 @@
 library
     build-depends:   base                     >= 4         && < 5
                    , template-haskell
-                   , persistent               >= 2.0.1     && < 2.1
+                   , persistent               >= 2.0.2     && < 2.1
                    , monad-control            >= 0.2       && < 0.4
                    , bytestring               >= 0.9
                    , text                     >= 0.5
