{"record":{"id":"4e84ed32547c6942","repo":"dotnet/efcore","slug":"entity-type-entitytype-is-sealed-usechangetr","errorCode":null,"errorMessage":"Entity type '{entityType}' is sealed. 'UseChangeTrackingProxies' requires all entity types to be public, unsealed, have virtual properties, and have a public or protected constructor. 'UseLazyLoadingProxies' requires only the navigation properties be virtual.","messagePattern":"Entity type '(.+?)' is sealed\\. 'UseChangeTrackingProxies' requires all entity types to be public, unsealed, have virtual properties, and have a public or protected constructor\\. 'UseLazyLoadingProxies' requires only the navigation properties be virtual\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Proxies/Proxies/Internal/ProxyBindingRewriter.cs","lineNumber":74,"sourceCode":"        IConventionContext<IConventionModelBuilder> context)\n    {\n        if (_options?.UseProxies == true)\n        {\n            modelBuilder.HasAnnotation(ProxyAnnotationNames.LazyLoading, _options.UseLazyLoadingProxies);\n            modelBuilder.HasAnnotation(ProxyAnnotationNames.ChangeTracking, _options.UseChangeTrackingProxies);\n            modelBuilder.HasAnnotation(ProxyAnnotationNames.CheckEquality, _options.CheckEquality);\n\n            foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())\n            {\n                var clrType = entityType.ClrType;\n                if (clrType.IsAbstract)\n                {\n                    continue;\n                }\n\n                if (clrType.IsSealed)\n                {\n                    throw new InvalidOperationException(ProxiesStrings.ItsASeal(entityType.DisplayName()));\n                }\n\n                foreach (var navigationBase in entityType.GetDeclaredNavigations()\n                             .Concat<IConventionNavigationBase>(entityType.GetDeclaredSkipNavigations()))\n                {\n                    if (!navigationBase.IsShadowProperty())\n                    {\n                        if (_options.UseChangeTrackingProxies)\n                        {\n                            if (navigationBase.PropertyInfo == null)\n                            {\n                                throw new InvalidOperationException(\n                                    ProxiesStrings.FieldProperty(navigationBase.Name, entityType.DisplayName()));\n                            }\n\n                            if (navigationBase.PropertyInfo.SetMethod?.IsReallyVirtual() == false)\n                            {\n                                throw new InvalidOperationException(","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Proxies/Proxies/Internal/ProxyBindingRewriter.cs#L56-L92","documentation":"ProxyBindingRewriter throws ItsASeal when an entity type's CLR type is sealed and proxies are enabled (ProxyBindingRewriter.cs:72-75). Dynamic proxy generation (subclassing) cannot subclass a sealed type, so lazy-loading or change-tracking proxies are impossible for it.","triggerScenarios":"Enabling UseChangeTrackingProxies or UseLazyLoadingProxies when any non-abstract entity type is declared 'sealed'.","commonSituations":"Applying proxy options to an existing model whose entity classes are sealed, or a code generator/source generator emitting sealed entities.","solutions":["Remove the 'sealed' modifier from the entity class so a proxy subclass can be generated.","Stop using proxies for that entity type (drop UseChangeTrackingProxies/UseLazyLoadingProxies)."],"exampleFix":"// before\npublic sealed class Blog { public int Id { get; set; } }\n// after\npublic class Blog { public int Id { get; set; }","handlingStrategy":"validation","validationCode":"// Reject sealed entity types before enabling proxies:\nstatic bool CanProxy(Type t) => !t.IsSealed && t.IsClass && !t.IsAbstract;\nforeach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    if (!CanProxy(et.ClrType))\n        throw new InvalidOperationException($\"{et.ClrType} must not be sealed to use proxies.\");\n}","typeGuard":"static bool IsProxyable(Type t) => t.IsClass && !t.IsAbstract && !t.IsSealed;","tryCatchPattern":null,"preventionTips":["Do not seal entity classes when using proxies.","Audit entity classes for the 'sealed' modifier before enabling proxies.","Prefer abstract or non-sealed entity base types."],"tags":["ef-core","proxies","change-tracking-proxies","lazy-loading-proxies","model-design"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}