- I have model with data.
- For some reasons one entity was moved from one namespace to another.
- After run on PerformSafely and select entity throw exception
"Type with TypeId=N is not registered."
See testcase below
(Initial model)
namespace ConsoleApplication1
{
using System;
using Xtensive.Orm;
[HierarchyRoot]
public class A : Entity
{
[Key]
[Field(Nullable = false)]
public Guid Id { get; set; }
[Field]
public string BaseStr { get; set; }
}
public class Ab : A
{
[Field]
public string Str { get; set; }
}
}
First run (Recreate)
namespace ConsoleApplication1
{
using System.Linq;
using System.Reflection;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;
public static class Program
{
static void Main(string[] args)
{
var configuration = DomainConfiguration.Load("Default");
configuration.UpgradeMode = DomainUpgradeMode.Recreate;
configuration.NamingConvention = new NamingConvention { NamingRules = NamingRules.UnderscoreDots };
configuration.Sessions.Add(new SessionConfiguration("Default")
{
BatchSize = 25,
CacheSize = 1000,
DefaultCommandTimeout = 6000,
Options =
SessionOptions.Default
| SessionOptions.AutoTransactionOpenMode
| SessionOptions.AutoTransactionSuppressMode
| SessionOptions.AutoActivation
});
configuration.Types.Register(Assembly.GetExecutingAssembly());
var domain = Domain.Build(configuration);
using (var s = domain.OpenSession())
{
using (s.Activate())
{
using (var t = s.OpenTransaction())
{
var a = new A();
var ab = new Ab();
t.Complete();
}
using (var t = s.OpenTransaction())
{
Session.Current.Query.All<A>().ToArray();
}
}
}
}
}
}
Then change namespace for "A". New model:
namespace ConsoleApplication1
{
using ConsoleApplication1.Abc;
using Xtensive.Orm;
public class Ab : A
{
[Field]
public string Str { get; set; }
}
}
namespace ConsoleApplication1.Abc
{
using System;
using Xtensive.Orm;
[HierarchyRoot]
public class A : Entity
{
[Key]
[Field(Nullable = false)]
public Guid Id { get; set; }
[Field]
public string BaseStr { get; set; }
}
}
Second run on PerformSafely throw exception:
"Type with TypeId=100 is not registered."
StackTrace:
at Xtensive.Orm.Model.TypeInfoCollection.get_Item(Int32 typeId)
at Xtensive.Orm.Linq.Materialization.MaterializationContext.GetTypeMapping(Int32 entityIndex, TypeInfo approximateType, Int32 typeId, Pair`1[] columns)
at Xtensive.Orm.Linq.Materialization.ItemMaterializationContext.Materialize(Int32 entityIndex, Int32 typeIdIndex, TypeInfo type, Pair`1[] entityColumns, Tuple tuple)
at lambda_method(Closure , Object[] , Tuple , ItemMaterializationContext )
at Xtensive.Core.DelegateBindExtensions.<>c__DisplayClass7`4.<Bind>b__6(T2 arg2, T3 arg3)
at Xtensive.Orm.Linq.Materialization.MaterializationHelper.<>c__DisplayClass4`1.<Materialize>b__3(Tuple tuple)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.EnumerableExtensions.<Batch>d__20`1.MoveNext()
at Xtensive.Core.EnumerableExtensions.<ApplyBeforeAndAfter>d__28`1.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at ConsoleApplication1.Program.Main(String[] args) in d:\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 48
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
asked
Mar 31 '14 at 08:58
Anton Guschin
73●30●30●35
Hello Anton, could you also provide the version of DataObjects.Net you're using?
What a speed!) 4.6.4
Hello Anton, I can confirm your problem. TypeId is not preserved correctly in your scenario. Please wait for the fix.