anchor.diff:              , IsErased = false
               )
       let fields = ResizeArray()
  -    let addField name fieldTy =
  +    let addField pk name fieldTy =
           let camel = toCamelCase name
           let field = ProvidedField("_" + camel, fieldTy)
           field.SetFieldAttributes(FieldAttributes.Private)
           let getter = ProvidedProperty(name, fieldTy)
  +        if pk then
  +            getter.AddCustomAttribute(KeyType.AttributeData)
           getter.GetterCode <-
  -            function | [ this ] -> Expr.FieldGet(this, field) | _ -> failwith "Invalid getter argument list"
  +            function
  +            | [ this ] -> Expr.FieldGet(this, field)
  +            | _ -> failwith "Invalid getter argument list"
           ty.AddMembers [ field :> MemberInfo; getter :> _ ]
           fields.Add(camel, field)
       for KeyValue(name, (_, column)) in columnMap.Columns do
  -        addField name <| model.Backend.MapPrimitiveType(column.ColumnType)
  +        addField column.PrimaryKey name <| model.Backend.MapPrimitiveType(column.ColumnType)
       for KeyValue(name, subMap) in columnMap.SubMaps do
           let subTy = generateRowTypeFromColumns model name subMap
           ty.AddMember(subTy)
  -        addField name subTy
  +        addField false name subTy
       let ctorParams = [ for camel, field in fields -> ProvidedParameter(camel, field.FieldType) ]
       let ctor = ProvidedConstructor(ctorParams)
       ctor.InvokeCode <-
  
positive.code: let private toCamelCase (str : string) =
      Regex.Replace(str, @"^\p{Lu}+", fun m -> m.Value.ToLowerInvariant())
  
  let rec private generateRowTypeFromColumns (model : UserModel) name (columnMap : CompileTimeColumnMap) =
      let ty =
          ProvidedTypeDefinition
  
negative.code:     ty
  
  let private generateRowType (name : string) (model : UserModel) (query : SchemaQuery) =
      CompileTimeColumnMap.Parse(query.Columns)
      |> generateRowTypeFromColumns model name
  
  let generateType generate =
      let baseType = typeof<obj> // TODO pick base command type based on result sets
  