You can do either of the following:
-
EF Core suggests initializing to
null!
with null-forgiving operatorpublic string ServiceUrl { get; set; } = null! ; //or public string ServiceUrl { get; set; } = default! ;
-
Using backing field:
private string _ServiceUrl; public string ServiceUrl { set => _ServiceUrl = value; get => _ServiceUrl ?? throw new InvalidOperationException("Uninitialized property: " + nameof(ServiceUrl)); }