anchor.diff:              // Generate new type for the record
               let ctx =
                   if not topLevel then
  -                    let name = defaultArg name "Record" |> ctx.UniqueNiceName
  +                    let name = defaultArg name "Record" |> ctx.UniqueTypeName
                       let objectTy = ProvidedTypeDefinition(name, Some ctx.IBsonTopType, HideObjectMethods = true)
                       ctx.TypeProviderType.AddMember(objectTy)
  -
  -                    { ctx with TypeProviderType = objectTy
  -                               UniqueNiceName = NameUtils.uniqueGenerator NameUtils.nicePascalName }
  +                    BsonGenerationContext.Create(objectTy)
                   else ctx
   
               // to nameclash property names
  
positive.code: type BsonGenerationContext =
      {
          TypeProviderType : ProvidedTypeDefinition
          UniqueNiceName : string -> string // to nameclash type names
          IBsonTopType : Type
          BsonValueType : Type
          BsonRuntimeType : Type
          TypeCache : Dictionary<InferedType, ProvidedTypeDefinition>
          GenerateConstructors : bool
      }
  
      static member Create(tpType, ?uniqueNiceName, ?typeCache) =
          let uniqueNiceName = defaultArg uniqueNiceName (NameUtils.uniqueGenerator NameUtils.nicePascalName)
          let typeCache = defaultArg typeCache (Dictionary())
          BsonGenerationContext.Create(tpType, uniqueNiceName, typeCache, true)
  
      static member Create(tpType, uniqueNiceName, typeCache, generateConstructors) =
          {
              TypeProviderType = tpType
              UniqueNiceName = uniqueNiceName
              IBsonTopType = typeof<IBsonTop>
              BsonValueType = typeof<BsonValue>
              BsonRuntimeType = typeof<BsonRuntime>
              TypeCache = typeCache
              GenerateConstructors = generateConstructors
          }
  
      member x.MakeOptionType(typ:Type) =
          typedefof<option<_>>.MakeGenericType typ
  
negative.code: 
              ctx.TypeProviderType.AddMembers properties
  
              // Generate constructors
              ctx.TypeProviderType.AddMember <| mkDefaultCtor ctx
  
              match parameters with
              | [ prop ] when prop.ParameterType = ctx.BsonValueType -> ()
              | _ -> ctx.TypeProviderType.AddMember <| mkCtor parameters
  
              ctx.TypeProviderType
  
  