InvalidOperationException ("Type 'ConsoleApplication1.Recycled' is not found.")

StackTrace:

at Xtensive.Orm.Upgrade.HintGenerator.ValidateRenameTypeHints(IEnumerable`1 hints)
at Xtensive.Orm.Upgrade.HintGenerator.ValidateHints(NativeTypeClassifier`1 hints)
at Xtensive.Orm.Upgrade.HintGenerator.Run()
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.BuildSchemaHints(StorageModel extractedSchema)
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.GetSchemaHints(StorageModel extractedSchema, StorageModel targetSchema)
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.SynchronizeSchema(Domain domain, SchemaUpgrader upgrader, SchemaExtractor extractor, SchemaUpgradeMode schemaUpgradeMode)
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.PerformUpgrade(Domain domain, UpgradeStage stage)
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.BuildMultistageDomain()
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Run()
at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)
at Xtensive.Orm.Domain.Build(DomainConfiguration configuration)
at ConsoleApplication1.Program.Main(String[] args) in d:\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 23

Code

using System;

using Xtensive.Orm;
using Xtensive.Orm.Configuration;
using Xtensive.Orm.Upgrade;

public static class Program
{
    static void Main(string[] args)
    {
        var dc = new DomainConfiguration("sqlserver://localhost/DO40-Tests");
        dc.Types.Register(typeof(Recycled));
        dc.Types.Register(typeof(Test));
        dc.UpgradeMode = DomainUpgradeMode.Recreate;

        using (var domain = Domain.Build(dc)) { }

        dc = dc.Clone();
        dc.UpgradeMode = DomainUpgradeMode.PerformSafely;

        using (var domain = Domain.Build(dc)) { }
    }
}

[HierarchyRoot]
[Recycled]
public class Recycled : Entity
{
    [Key]
    [Field(Nullable = false)]
    public Guid Id { get; set; }

    [Field]
    public string Name { get; set; }
}

[HierarchyRoot]
public class Test : Entity
{
    [Key]
    [Field(Nullable = false)]
    public Guid Id { get; set; }

    [Field]
    public string Name { get; set; }

    [Field]
    [Recycled]
    public Recycled Link { get; set; }
}

asked May 14 '14 at 02:52

Anton%20Guschin's gravatar image

Anton Guschin
73273035

Version DO 4.6.6

(May 16 '14 at 07:27) Anton Guschin Anton%20Guschin's gravatar image

One Answer:

Hello Anton.

Technically, there is nothing wrong with this behavior. You use same model in both cases. In the first case DataObjects.Net ignore all recycled types and doesn't create tables. In the second case, DataObjects.Net tries to create RenameTypeHint for each type which marked as recycled. But it does not find ConsoleApplication1.Recycled in old model, because ConsoleApplication1.Recycled wasn't created in database in the first case.

RecycledAttribute helps to rename type without manual creation of RenameTypeHint on upgrade from one model to another. If old name of type was not defined in attribute, DataObjects.Net tries to remove specified suffix from namespace of new type and defines name of old type by this value.

But logically, it is incorrect behavior. Dataobjects.Net should not create hints automatically or must throw exception if it does not find type with old name in old model.

Thank you for your report. We will fix it in next version of DataObjects.Net.

answered Jun 04 '14 at 04:51

Alexey%20Kulakov's gravatar image

Alexey Kulakov
51215

Small, but important notice:

1 Throw exception doesn't resolve our issue.

For example, we have initial scheme, mark some types with [Recycled], do 'Perform', change more models (still have old [Recycled] attributes), do 'Perform' (on this step we already have scheme without recycled types in DB, but, I think, nothing wrong with it)

Don't create hints will be much more better.

2 What about resolve time? Next version - is hotfix, or something else? Worried about that, becouse other similar bug hanging from February (http://support.x-tensive.com/question/5895/bug-with-recycled-nested-type)

(Jun 10 '14 at 01:56) Anton Guschin Anton%20Guschin's gravatar image

Hi Anton. Both bugs have already fixed. We plan to release next version very soon.

(Jun 10 '14 at 23:33) Alexey Kulakov Alexey%20Kulakov's gravatar image

Oh, great! Thx!

(Jun 11 '14 at 01:01) 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