hez2010 / EFCore.NativeAOT

A sample showing how to use Entity Framework Core with NativeAOT
33 stars 5 forks source link

<System.Guid> is missing metadata #4

Closed newonejoe closed 2 years ago

newonejoe commented 2 years ago

Hi @hez2010 ,

你好,我跟着你的项目自己做了一个demo,添加了一共四个model,其中三个以Int32为主键的都没有问题,但是最后一个ProductionRecord以为主键遇到了如下报错。

我的Demo的链接.

Navtive Code App已经能生成了和运行,但是在响应API请求的时候,出现如下报错。尝试了很长时间不能解决,应该是rd.xml有问题,请帮忙分析下。

Error:

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://0.0.0.0:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\cn101143\source\repos\Logger\Logger\bin\Release\net6.0\win-x64\publish\
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMEBHEGPALR3", Request id "0HMEBHEGPALR3:00000002": An unhandled exception was thrown by the application.
      System.Reflection.MissingMetadataException: 'Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot<System.Guid>' is missing metadata. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=392859
         at System.Reflection.Runtime.General.TypeUnifier.WithVerifiedTypeHandle(RuntimeConstructedGenericTypeInfo, RuntimeTypeInfo[]) + 0x8e
         at System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.MakeGenericType(Type[]) + 0x22c
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot.CreateSnapshotType(Type[]) + 0x49
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.SnapshotFactoryFactory.CreateSnapshotExpression(Type, ParameterExpression, Type[], IList`1) + 0x336
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.SnapshotFactoryFactory.CreateConstructorExpression(IEntityType, ParameterExpression) + 0x51f
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.SnapshotFactoryFactory`1.Create(IEntityType) + 0xcf
         at Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType.Microsoft.EntityFrameworkCore.Metadata.Internal.IRuntimeEntityType.get_RelationshipSnapshotFactory() + 0x63
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureRelationshipSnapshot() + 0x2f
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.SnapshotAndSubscribe(InternalEntityEntry) + 0x36
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry) + 0xaa         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState, EntityState, Boolean, Boolean) + 0x45f
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.<SetEntityStateAsync>d__27.MoveNext() + 0x198
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.<PaintActionAsync>d__5.MoveNext() + 0x1fb
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.<TraverseGraphAsync>d__1`1.MoveNext() + 0x137
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.<AttachGraphAsync>d__3.MoveNext() + 0x2c5
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.<AddAsync>d__19.MoveNext() + 0x270
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Logger.Controllers.ProductionRecordsController.<GetProductionRecords>d__2.MoveNext() + 0x2fe
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() + 0x1f
         at Logger!<BaseAddress>+0x16bd816
         at System.InvokeUtils.CallDynamicInvokeMethod(Object, IntPtr, IntPtr, IntPtr, Object, Object[], BinderBundle, Boolean, Boolean) + 0x113
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow(TargetInvocationException) + 0x17
         at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run(InterpretedFrame) + 0x259
         at System.Linq.Expressions.Interpreter.Interpreter.Run(InterpretedFrame) + 0x2d
         at System.Linq.Expressions.Interpreter.LightLambda.Run(Object[]) + 0x80
         at Logger!<BaseAddress>+0x132ad3c
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.<Execute>d__0.MoveNext() + 0x183
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Awaited|12_0>d.MoveNext() + 0x160
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeNextActionFilterAsync>g__Awaited|10_0>d.MoveNext() + 0xa5
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ControllerActionInvoker.ActionExecutedContextSealed) + 0x3a
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ControllerActionInvoker.State&, ControllerActionInvoker.Scope&, Object&, Boolean&) + 0x6bd
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() + 0x42
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<<InvokeFilterPipelineAsync>g__Awaited|20_0>d.MoveNext() + 0xa5
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<<InvokeAsync>g__Awaited|17_0>d.MoveNext() + 0xbd
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<<InvokeAsync>g__Awaited|17_0>d.MoveNext() + 0x208
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<<Invoke>g__AwaitRequestTask|6_0>d.MoveNext() + 0xa8
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.<Invoke>d__6.MoveNext() + 0x25c
      --- End of stack trace from previous location where exception was thrown ---
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb9
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.<ProcessRequests>d__223`1.MoveNext() + 0x43e

Related rd.xml

<Directives>
  <Application>
    <Assembly Name="Logger">
      <Type Name="Logger.Controllers.ErrorsController" Dynamic="Required All" />
      <Type Name="Logger.Controllers.JobStatesController" Dynamic="Required All" />
      <Type Name="Logger.Controllers.MeasurementDatasController" Dynamic="Required All" />
      <Type Name="Logger.Controllers.ProductionRecordsController" Dynamic="Required All" />
    </Assembly>

    <Assembly Name="Microsoft.EntityFrameworkCore.Relational" Dynamic="Required All">
      <Type Name="Microsoft.EntityFrameworkCore.Update.Internal.KeyValueIndexFactorySource" Dynamic="Required All">
        <Method Name="CreateFactory" Dynamic="Required">
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
        </Method>
        <Method Name="CreateFactory" Dynamic="Required">
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
        </Method>
        <Method Name="CreateFactory" Dynamic="Required">
          <GenericArgument Name="System.Guid,System.Private.CoreLib" />
        </Method>
        <Method Name="CreateFactory" Dynamic="Required">
          <GenericArgument Name="System.Double,System.Private.CoreLib" />
        </Method>
        <Method Name="CreateFactory" Dynamic="Required">
          <GenericArgument Name="System.Boolean,System.Private.CoreLib" />
        </Method>
      </Type>
    </Assembly>

    <Assembly Name="Microsoft.EntityFrameworkCore.Sqlite" Dynamic="Required All" />

    <Assembly Name="Microsoft.EntityFrameworkCore" Dynamic="Required All">
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.EntryCurrentValueComparer`1[[System.Int32,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.EntryCurrentValueComparer`1[[System.Guid,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.Int32,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.DateTime,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.Boolean,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.Double,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer`1[[System.Guid,System.Private.CoreLib]]" Dynamic="Required All" />
      <!--DbSet<JobState> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.JobState,Logger],[System.Int32,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.JobState,Logger" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<JobState> ClrPropertyGetterFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.JobState,Logger" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<Error> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.Error,Logger],[System.Int32,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.Error,Logger" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<Error> ClrPropertyGetterFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.Error,Logger" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<MeasurementData> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.MeasurementData,Logger],[System.Int32,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.MeasurementData,Logger" />
          <GenericArgument Name="System.Boolean,System.Private.CoreLib" />
          <GenericArgument Name="System.Boolean,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<MeasurementData> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.MeasurementData,Logger],[System.Int32,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.MeasurementData,Logger" />
          <GenericArgument Name="System.Double,System.Private.CoreLib" />
          <GenericArgument Name="System.Double,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<MeasurementData> ClrPropertyGetterFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.MeasurementData,Logger" />
          <GenericArgument Name="System.Boolean,System.Private.CoreLib" />
          <GenericArgument Name="System.Boolean,System.Private.CoreLib" />
        </Method>
      </Type>

      <!--DbSet<ProductionRecord> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.ProductionRecord,Logger],[System.Guid,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.Guid,System.Private.CoreLib" />
          <GenericArgument Name="System.Guid,System.Private.CoreLib" />
        </Method>
      </Type>

      <!--DbSet<ProductionRecord> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.ProductionRecord,Logger],[System.Guid,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
        </Method>
      </Type>
      <!--DbSet<ProductionRecord> ClrAccessorFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1[[Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetter`2[[Logger.Model.ProductionRecord,Logger],[System.Guid,System.Private.CoreLib]],Microsoft.EntityFrameworkCore]]" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
        </Method>
      </Type>

      <!--DbSet<ProductionRecord> ClrPropertyGetterFactory -->
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.Guid,System.Private.CoreLib" />
          <GenericArgument Name="System.Guid,System.Private.CoreLib" />
        </Method>
      </Type>

      <!--DbSet<ProductionRecord> ClrPropertyGetterFactory --><!--
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
          <GenericArgument Name="System.Int32,System.Private.CoreLib" />
        </Method>
      </Type>
      --><!--DbSet<ProductionRecord> ClrPropertyGetterFactory --><!--
      <Type Name="Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory" Dynamic="Required All">
        <Method Name="CreateGeneric" Dynamic="Required All">
          <GenericArgument Name="Logger.Model.ProductionRecord,Logger" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
          <GenericArgument Name="System.DateTime,System.Private.CoreLib" />
        </Method>
      </Type>-->

      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`1[[System.Int32,System.Private.CoreLib]]" Dynamic="Required All" />
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`2[[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />
      <!--DbSet<JobState> EFCore ChangeTracking Snapshot-->
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`7[[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.DateTime,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />
      <!--DbSet<Error> EFCore ChangeTracking Snapshot-->
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`7[[System.Int32,System.Private.CoreLib],[System.DateTime,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />
      <!--DbSet<MeasurementData> EFCore ChangeTracking Snapshot-->
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`9[[System.Int32,System.Private.CoreLib],[System.DateTime,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.Double,System.Private.CoreLib],[System.Boolean,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />
      <!--DbSet<ProductionRecord> EFCore ChangeTracking Snapshot-->
      <Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`19[[System.Guid,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.DateTime,System.Private.CoreLib],[System.DateTime,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.String,System.Private.CoreLib],[System.Int32,System.Private.CoreLib],[System.String,System.Private.CoreLib]]" Dynamic="Required All" />

  </Application>
</Directives>
hez2010 commented 2 years ago

尝试添加:

<Type Name="Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot`1[[System.Guid,System.Private.CoreLib]]" Dynamic="Required All" />
hez2010 commented 2 years ago

帮你看了一下,除了上面说的那一条之外,还需要下面这些:

     <Type Name="Microsoft.EntityFrameworkCore.EF" Dynamic="Required All">
       <Method Name="Property" Dynamic="Required">
         <GenericArgument Name="System.Int32,System.Private.CoreLib" />
       </Method>
       <Method Name="Property" Dynamic="Required">
         <GenericArgument Name="System.Guid,System.Private.CoreLib" />
       </Method>
     </Type>
newonejoe commented 2 years ago

加上第一条的内容就可以了,我觉得可以做一个rd.xml内容的生成器,根据dbcontext内的dbset和其引用自动生成,这样就可以大大简化流程和时间,现在都是根据报错来改rd.xml。 总体来说要

内的 Microsoft.EntityFrameworkCore.ChangeTracking.EntryCurrentValueComparer Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer+DefaultValueComparer Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory Microsoft.EntityFrameworkCore.Metadata.Internal.ClrPropertyGetterFactory Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Snapshot Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMapFactoryFactory Microsoft.EntityFrameworkCore.Metadata.Internal.PropertyAccessorsFactory Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry