Skip to content

"$type" property is missing after data migration #144

@bibalek

Description

@bibalek

Hi,
We have a typed data structure with data models based on class inheritance.
To save/read data on cosmosdb we use Newtonsoft (de)serialization which normally works fine. Example of data model:

public class Pet
{
    public string Name { get; set; }
}

public class Dog : Pet
{
    public string OtherName { get; set }
}

This is a piece of saved document how it is persisted:

{
  ...,
  "myFavouritePet": {
    "$type": "MyProject.Pets.Dog, MyProject",
    "Name": "Foo",
    "OtherName": "OtherFoo"
  },
  ...
}

After running the migration tool, from cosmos-nosql source to json or other cosmos-nosql sink, the migrated data contains everything except the "$type" property:

{
  ...,
  "myFavouritePet": {
    "Name": "Foo",
    "OtherName": "OtherFoo"
  },
  ...
}

Not sure if that is internal tool issue or rather the configuration. Here is the exemplary setting I use:

{
  "Source": "cosmos-nosql",
  "Sink": "cosmos-nosql",
  "SourceSettings": {
    "UseRbacAuth": true,
    "AccountEndpoint": "https://...",
    "EnableInteractiveCredentials": true,
    "Database": "mySourceDb",
    "Container": "mySourceContainer",
    "IncludeMetadataFields": true,
    "InitClientEncryption": false,
  },
  "SinkSettings": {
    "ConnectionString": "AccountEndpoint=https://...;AccountKey=...",
    "Database": "myDatabase",
    "Container": "myContainer",
    "PartitionKeyPath": "myPartitionKeyPath",
    "RecreateContainer": true,
    "IncludeMetadataFields": true,
    "WriteMode": "InsertStream",
    "PreserveMixedCaseIds": true,
  },
}

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions