'Using C# 9 records "with" expression can I copy and add to new derived instance?

Suppose I have the following:

public record Settings 
{
  public int Setting1 { get; init; }
}

public record MoreSettings : Settings
{
  public string Setting2 { get; init; }
}
...

var settings = new Settings { Setting1 = 1 };

// This is an error - CS0117
MoreSettings moreSettings = settings with { Setting2 = "A string setting" };

Is there a clean way to achieve this? Do I have the syntax wrong?
Obviously, in this contrived case I could just manually copy each base property.

var moreSettings = new MoreSettings { Setting1 = settings.Setting1, Setting2 = "A String!" };

But what if the base record type has lots of properties?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source