> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# .NET (server-side) SDK 7.x to 8.0 migration guide

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

This topic explains the changes in the .NET (server-side) SDK 8.0 release and how to migrate to that version.

**Version 8.0 includes breaking changes**. It removes the deprecated `LDUser`. To learn more, read [Understanding what was removed](#understanding-what-was-removed). Additionally, if you use the Relay Proxy, you must update your Relay Proxy to version 8.0 before you update your SDK to version 8.0. To learn more, read the [Relay Proxy 8.0 release notes](https://github.com/launchdarkly/ld-relay/releases/tag/v8.0.0). To upgrade to the latest Relay Proxy version, visit [Relay Proxy releases](https://github.com/launchdarkly/ld-relay/releases) on GitHub.

Version 8.0 of the SDK introduces the ability to manage migrations or modernizations. You might use this functionality if you are optimizing queries, upgrading to new tech stacks, migrating from one database to another, or other similar technology changes.

You will need this functionality to use migration flags. A migration flag is a temporary flag used to migrate data or systems while keeping your application available and disruption free. To learn more, read [Migration flags](/docs/home/flags/migration).

Version 8.0 of the SDK also introduces the ability to configure the SDK to send application metadata to LaunchDarkly.

Before you migrate to version 8.0, we recommend updating to the latest 7.x version. If you update to the latest 7.x version, deprecation warnings appear in areas of your code that need to be changed for 8.0, for example, any use of `LDUser`. You can update these areas at your own pace while still using 7.x, rather than migrating everything simultaneously. To learn more about updating to the latest 7.x version, visit the [SDK's GitHub repository](https://github.com/launchdarkly/dotnet-server-sdk).

## Understanding how to manage a migration

Depending on how you created your migration feature flag, your migration will have two, four, or six stages. At each stage, you will be reading data from the old system, the new system, or both. You will also be writing data to the old system, the new system, or both. At each stage, only one of these destinations is considered the authoritative source. In the LaunchDarkly SDK, you can determine which stage of the migration your application is currently in, execute the appropriate read and write methods, and then compare the results to check correctness and view any errors or changes in latency.

To manage your migration:

* [Configure the migration](#configuring-the-migration)
* [Call the read and write methods you defined](#reading-and-writing-during-the-migration)

### Configuring the migration

There are two categories of migration options that you can configure for each LaunchDarkly SDK:

* Options for reading and writing data: You can define how to read from and write to both the old system and the new system. You can also define a method to check whether the two reads are a match, and whether the migration should execute serially or concurrently. To learn how these options apply to each migration stage, read [Use SDKs to manage a migration](/docs/sdk/features/migrations#use-sdks-to-manage-a-migration).
* Options for tracking metrics: You can configure whether the SDK should track latency and errors, so that you can monitor the performance of your application during the migration.

Here's how:

<CodeGroup>
  ```csharp title=".NET SDK v8.0 (C#)" expandable lines wrap theme={null}

  // define how to compare the two read values
  bool Checker(string a, string b) => a.Equals(b);

  var migration = new MigrationBuilder<string, string, string, string>(_client)
      .Read(
          (payload) => MigrationMethod.Success("read old"),
          (payload) => MigrationMethod.Success("read new"),
          Checker)
      .Write(
          (payload) => MigrationMethod.Success("write old"),
          (payload) => MigrationMethod.Success("write new"))
      .ReadExecution(MigrationExecution.Parallel()) // or MigrationExecution.Serial(MigrationSerialOrder.Fixed)
      .TrackErrors(true)    // true by default
      .TrackLatency(true)   // true by default
      .Build();

  ```
</CodeGroup>

To learn more, read [Migration configuration](/docs/sdk/features/migration-config).

### Reading and writing during the migration

As your migration proceeds, use the SDK's migrator to call the read and write methods you defined. The migrator determines the migration stage of the feature flag controlling the migration, and performs reads and writes to the old and new systems based on the migration stage.

Here's how:

<CodeGroup>
  ```csharp title=".NET SDK v8.0 (C#)" lines wrap theme={null}
  LDContext context = Context.Builder("example-context-key")
      .Build();

  // this is the migration stage to use if the flag's migration stage
  // is not available from LaunchDarkly
  var defaultStage = MigrationStage.Off;

  var readResult = migration.Read("example-migration-flag-key", context, defaultStage, payload);

  var writeResult = migration.Write("example-migration-flag-key", context, defaultStage, payload);

  ```
</CodeGroup>

To learn more, read [Migrations](/docs/sdk/features/migrations).

During the migration, you can check the consistency, errors, and latency as you manage your migration. This information is available in the "Migration insights" section of the flag's **Targeting** tab. To learn more, read [Migration flags](/docs/home/flags/migration).

## Understanding application metadata

Version 8.0 introduces the ability to configure the .NET (server-side) SDK to send application metadata to LaunchDarkly. The SDK now supports configuration options for specifying application information, including application identifier and version. When you configure these options, the SDK automatically sends this application information to LaunchDarkly.

In the LaunchDarkly user interface (UI), the application information appears in the "From source" field on Context details pages. To learn more, read [The context details page](/docs/home/flags/context-details).

You can set these values when you configure the SDK. All connections to LaunchDarkly from a client will send the same value to LaunchDarkly, whether the connection is through streaming, polling, or events. You cannot change the value after you configure the client.

Here's how:

<CodeGroup>
  ```csharp title=".NET SDK v8 (C#)" lines wrap theme={null}

  var config = Configuration.Builder("YOUR_SDK_KEY")
      .ApplicationInfo(Components.ApplicationInfo()
          .ApplicationID("authentication-service")
          .ApplicationName("Authentication-Service")
          .ApplicationVersion("1.0.0")
          .ApplicationVersionName("v1")
      )
      .Build();

  var client = new LdClient(config);

  ```
</CodeGroup>

To learn more, read [Application metadata configuration](/docs/sdk/features/app-config).

## Understanding what was removed

**Version 8.0 removes the deprecated `LDUser`**. Version 7 of the .NET (server-side) SDK replaced users with contexts. Starting in version 8, the deprecated `LDUser` is removed.

Here's how to construct a basic context, as compared with constructing a user:

<CodeGroup>
  ```csharp title=".NET SDK v6.x, user with key" lines wrap theme={null}
  var user1 = User.WithKey("example-user-key");
  ```

  ```csharp title=".NET SDK v7+, context with key" lines wrap theme={null}
  // To specify just the key, use New.
  // By default, the context kind is "user."
  var context1 = Context.New("example-context-key");

  ```
</CodeGroup>

And here's how to evaluate a flag using a context:

<CodeGroup>
  ```csharp title=".NET SDK v7+" lines wrap theme={null}
  var value = client.BoolVariation("example-flag-key", context, false);
  ```
</CodeGroup>

To learn more about replacing users with contexts, read the [.NET (server-side) SDK 6.x to 7.0 migration guide](/docs/sdk/server-side/dotnet/migration-6-to-7) and [Best practices for upgrading users to contexts](/docs/guides/flags/upgrading-contexts).
