EnsureCreated выбрасывает "Индекс вышел за пределы массива". EF Core 5

Я получил "Индекс был за пределами массива.'проблема после обновления приложения для использования EF Core 5 Preview 6.

Одна сущность из моего контекста наследует базовый класс со строковым свойством. EnsureCreated не работает из-за этого.

Надеюсь, это поможет кому-то сэкономить время.


Пример кода: GitHub. Приложение выдает исключение в строке 46 App.cs

Трассировки стека:

  at System.Attribute.InternalParamGetCustomAttributes (System.Reflection.ParameterInfo parameter, System.Type attributeType, System.Boolean inherit) [0x0005b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/attribute.cs:62 
  at System.Attribute.GetCustomAttributes (System.Reflection.ParameterInfo element, System.Type attributeType, System.Boolean inherit) [0x0008b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/attribute.cs:686 
  at System.Attribute.GetCustomAttribute (System.Reflection.ParameterInfo element, System.Type attributeType, System.Boolean inherit) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/attribute.cs:754 
  at System.Attribute.GetCustomAttribute (System.Reflection.ParameterInfo element, System.Type attributeType) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/attribute.cs:747 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttribute (System.Reflection.ParameterInfo element, System.Type attributeType) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/reflection/CustomAttributeExtensions.cs:22 
  at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T] (System.Reflection.ParameterInfo element) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/reflection/CustomAttributeExtensions.cs:39 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.NonNullableConventionBase.IsNonNullableReferenceType (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder, System.Reflection.MemberInfo memberInfo) [0x00053] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.NonNullableReferencePropertyConvention.Process (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder) [0x00016] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.NonNullableReferencePropertyConvention.ProcessPropertyAdded (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder, Microsoft.EntityFrameworkCore.Metadata.Conventions.IConventionContext`1[TMetadata] context) [0x00000] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnPropertyAdded (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder) [0x00057] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+OnPropertyAddedNode.Run (Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher dispatcher) [0x0000c] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+DelayedConventionScope.Run (Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher dispatcher) [0x0001e] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Run () [0x000d5] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Dispose () [0x0001d] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnModelInitialized (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder) [0x0006f] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelInitialized (Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionModelBuilder modelBuilder) [0x00000] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Metadata.Internal.Model..ctor (Microsoft.EntityFrameworkCore.Metadata.Conventions.ConventionSet conventions) [0x00083] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.ModelBuilder..ctor (Microsoft.EntityFrameworkCore.Metadata.Conventions.ConventionSet conventions) [0x00012] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel (Microsoft.EntityFrameworkCore.DbContext context, Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure.IConventionSetBuilder conventionSetBuilder) [0x00012] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel (Microsoft.EntityFrameworkCore.DbContext context, Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure.IConventionSetBuilder conventionSetBuilder) [0x00046] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel () [0x0003c] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model () [0x00020] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder+<>c.<TryAddCoreServices>b__7_3 (System.IServiceProvider p) [0x00006] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory (Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryCallSite factoryCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context) [0x0000d] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSiteMain (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, TArgument argument) [0x00033] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngine, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverLock lockType) [0x00059] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite singletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context) [0x00029] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, TArgument argument) [0x00057] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor (Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite constructorCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context) [0x0002c] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSiteMain (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, TArgument argument) [0x0004f] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngine, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverLock lockType) [0x00059] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite singletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext context) [0x00029] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, TArgument argument) [0x00057] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00012] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.<RealizeService>b__0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0003e] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x0003d] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService (System.Type serviceType) [0x00013] in <4e78c4059cfa4c389aede5964cebac8d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, System.Type serviceType) [0x00034] in <d1acff4f0ecc47ed9eff84e41e448405>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T] (System.IServiceProvider provider) [0x0000e] in <d1acff4f0ecc47ed9eff84e41e448405>:0 
  at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies () [0x00017] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider () [0x000b5] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance () [0x00000] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.Internal.InfrastructureExtensions.GetService[TService] (Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure`1[T] accessor) [0x00005] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService] (Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure`1[T] accessor) [0x0000b] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.get_Dependencies () [0x0000a] in <408f3becd65240f9ac6a071d06d06520>:0 
  at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated () [0x00000] in <408f3becd65240f9ac6a071d06d06520>:0 
  at XamarinAndroidEfCoreApp.App.InitializeDatabase (System.String databaseLocationPath, System.String databaseName) [0x0000a] in D:\Workspace\Workflow\Projects\Samples\XamarinAndroidEfCoreApp\XamarinAndroidEfCoreApp\App.cs:46 
  at XamarinAndroidEfCoreApp.App.OnCreate () [0x0002d] in D:\Workspace\Workflow\Projects\Samples\XamarinAndroidEfCoreApp\XamarinAndroidEfCoreApp\App.cs:27 
  at Android.App.Application.n_OnCreate (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <94c63bf70a6244b090f8036e8ac91ed5>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)

0 ответов

Другие вопросы по тегам