dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.77k stars 3.18k forks source link

Lazy Loading EF Core and Hot Reload Problem #27398

Open vsfeedback opened 2 years ago

vsfeedback commented 2 years ago

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] Quando eu utilizo o Hot Reload do Visual Studio 2022 Community sempre costuma dar o erro abaixo com o ASP.NET Core 6:


      Method 'get_LazyLoader' on type 'Castle.Proxies.MapInfoProxy_1' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that has been overridden.
      System.TypeLoadException: Method 'get_LazyLoader' on type 'Castle.Proxies.MapInfoProxy_1' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that has been overridden.
         at System.Reflection.Emit.TypeBuilder.TermCreateClass(QCallModule module, Int32 tk, ObjectHandleOnStack type)
         at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
         at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
         at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.CreateType(TypeBuilder type)
         at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType()
         at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(String name, Type[] interfaces, INamingScope namingScope)
         at Castle.Core.Internal.SynchronizedDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
         at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory)
         at Microsoft.EntityFrameworkCore.Proxies.Internal.ProxyBindingRewriter.ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext`1 context)
         at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelFinalizing(IConventionModelBuilder modelBuilder)
         at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelFinalizing(IConventionModelBuilder modelBuilder)
         at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FinalizeModel()
         at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger`1 validationLogger)
         at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
         at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
         at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
         at Microsoft.EntityFrameworkCore.DbContext.get_Model()
         at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
         at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
         at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Linq.IQueryable.get_Provider()
         at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
         at Xttdenc.Web.Shared.PlayGame.CreateCharacter.CreateCharacterUserAsync()```

---
### Original Comments

#### Feedback Bot on 2/7/2022, 03:45 AM: 

<p>We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.</p>

---
### Original Solutions
(no solutions)
ajcvickers commented 2 years ago

See also #26914.