2

My project uses Code First Entity Framework (Version 6). My entity classes implement navigation properties as virtual properties. This must mean that EF built proxy classes using ReflectionEmit. This works fine if I execute the application normally. But when I debug my project in VisualStudio (2013), I get an exception (when executing the first request) explaining that there is a conflict in the creation of a type. Here is the stacktrace:

System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, Type enclosingType)
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType)
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType)
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
System.Data.Entity.Core.Objects.Internal.EntityProxyFactory.ProxyTypeBuilder.get_TypeBuilder()
System.Data.Entity.Core.Objects.Internal.EntityProxyFactory.ProxyTypeBuilder.CreateType(ModuleBuilder moduleBuilder)
System.Data.Entity.Core.Objects.Internal.EntityProxyFactory.BuildType(ModuleBuilder moduleBuilder, ClrEntityType ospaceEntityType, MetadataWorkspace workspace)
System.Data.Entity.Core.Objects.Internal.EntityProxyFactory.TryCreateProxyType(EntityType ospaceEntityType, MetadataWorkspace workspace)
System.Data.Entity.Core.Objects.Internal.EntityProxyFactory.GetProxyType(ClrEntityType ospaceEntityType, MetadataWorkspace workspace)

Is there a reason that Reflection.Emit does not work in the same way in this context compared to a standard execution?

nlips
  • 1,258
  • 9
  • 25

0 Answers0