locked
ASP.Net 3.1 : Error after updating Nuget Package RRS feed

  • Question

  • User-1602535186 posted

    I am having Asp.Net 3.1 application, and I am getting error After updating my nuget packages 'Microsoft.EntityFrameworkCore' in below line as

    'The specified field '_redirectUris' cannot be used for the property 'ClientApplication.RedirectUrisList' because it does not match the property name.'

    modelBuilder.Entity<TestApplication>().Property<string>("RedirectUrisList").HasField("_redirectUris");

    Tuesday, April 21, 2020 8:19 PM

All replies

  • User-854763662 posted

    Hi TechAspirant ,

    From the related github issue , it seems that this method still has problems in 3.0 and is not applicable

    Here is workaround to make modification as follows:

    Model

     public class TestApplication
        {
            private string _redirectUris;
    
            public int Id { get; set; }
    
            public string Name { get; set; }
    
            public string RedirectUrisList => _redirectUris;
        }

    DbContext

    modelBuilder.Entity<TestApplication>().Property(t=>t.RedirectUrisList).HasField("_redirectUris");

    Best Regards,

    Sherry

    Wednesday, April 22, 2020 6:22 AM
  • User-1602535186 posted

    I am getting error as below

    System.InvalidOperationException: 'The specified field '_redirectUris' of type 'string' cannot be used for the property 'ClientApplication.RedirectUris' of type 'IEnumerable<string>'. Only backing fields of types that are assignable from the property type can be used.'

    public IEnumerable<string> RedirectUris
        {
          get => EnumerationToStringConverter.CreateEnumerationFromString(_redirectUris);
          set => _redirectUris = EnumerationToStringConverter.CreateStringFromEnumeration(value, _redirectUris);
        }
    modelBuilder.Entity<TestApplication>().Property(t=>t.RedirectUrisList).HasField("_redirectUris");

    Wednesday, April 22, 2020 4:57 PM
  • User-474980206 posted

    Sql does not support a column as an array type, so there is no way to map a database field to a enumerator. It looks you really wanted to map to a enum, which can be done

    https://docs.microsoft.com/en-us/ef/core/modeling/value-conversions

    Wednesday, April 22, 2020 7:39 PM