1. I have model with data.
  2. For some reasons one entity was moved from one namespace to another.
  3. 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%20Guschin's gravatar image

Anton Guschin
73223035

Hello Anton, could you also provide the version of DataObjects.Net you're using?

(Mar 31 '14 at 09:04) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

What a speed!) 4.6.4

(Mar 31 '14 at 09:13) Anton Guschin Anton%20Guschin's gravatar image

Hello Anton, I can confirm your problem. TypeId is not preserved correctly in your scenario. Please wait for the fix.

(Apr 01 '14 at 06:07) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

One Answer:

We've just released DataObjects.Net 4.6.6 which includes fix for this problem.

Let us know if it worked for you.

answered Apr 09 '14 at 06:05

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Yeah, fixed. Thx a lot

(Apr 11 '14 at 05:37) Anton Guschin Anton%20Guschin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA