首页 > 解决方案 > .NET Core 3.1 - 设计器加载失败 - EntityFramework Core

问题描述

我有一个 .Net Core 3.1 项目(winforms)。对于每个表单,我都有一个所有表单都依赖的 baseForm。

在我的基类上,我有这个属性

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public DataContext con { get; set; }

DataContext 使用 EF Core 3.19 的地方。如果我尝试打开 Baseform 的任何后代形式的设计器,我会收到以下错误:

at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParametersNoCopy()
at System.Reflection.RuntimePropertyInfo.GetIndexParametersNoCopy()
at System.Reflection.RuntimePropertyInfo.GetIndexParameters()
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetProperties(Type type)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetProperties()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)
at System.ComponentModel.TypeDescriptor.GetProperties(Object component)
at Microsoft.DotNet.DesignTools.Serialization.CodeDomSerializerBase.GetPropertiesHelper(IDesignerSerializationManager manager, Object instance, Attribute[] attributes)
at Microsoft.DotNet.DesignTools.Serialization.CodeDomSerializerBase.DeserializePropertiesFromResources(IDesignerSerializationManager manager, Object value, Attribute[] filter)
at Microsoft.DotNet.DesignTools.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at Microsoft.DotNet.DesignTools.Sessions.Session.DeserializeToRootComponent(CodeTypeDeclaration typeDeclaration)
at Microsoft.DotNet.DesignTools.Sessions.Session.DeserializeRootComponent(CodeTypeDeclaration typeDeclaration, ResourceContentData[] resourceDocDataContent, String basePath)
at Microsoft.DotNet.DesignTools.Protocol.Endpoints.Sessions.InitializeRootComponentHandler.HandleRequest(InitializeRootComponentRequest request)
at Microsoft.DotNet.DesignTools.Protocol.Endpoints.RequestHandler`2.Microsoft.DotNet.DesignTools.Protocol.Endpoints.IRequestHandler.HandleRequest(Request request) 

与消息

Method 'DisposeAsync' in type 'Microsoft.EntityFrameworkCore.DbContext' from assembly 'Microsoft.EntityFrameworkCore, Version=3.1.19.0, ... does not have an implementation. 

尽管在我的 DataContext 中我已经实现了以下方法:

        public async ValueTask DisposeAsync()
        {   
            await DisposeAsyncCore();

            Dispose(disposing: false);
            #pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
            GC.SuppressFinalize(this);
            #pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
        }

有谁知道什么可能导致我的问题?我的设计师应该完全跳过 DataContext 属性..

标签: c#.netwinformsentity-framework-core

解决方案


推荐阅读