Hi,
I want to rename a Field of a Structure, but I can't find the right upgrader hint to do it.
I have tried the following hint :
hints.Add(new RenameFieldHint(typeof(MyEntity), "MyStructure.Name", "MyStructure.NewName"));
The hint is accepted by validateRenameFieldHints method and goes to the upgrader phase where i have the following exception (note the hint is not listed in Schema hints but the 'new RenameFieldHint' has been executed, I have double checked that by changing the name of a the 2nd argument in call of RenameFieldHint to a random property name and i do get the validateRenameFieldHints exception):
Xtensive.Orm.SchemaSynchronizationException: Extracted schema is not equal to the target schema. Details:
Schema comparison result: NotEqual
Has unsafe actions: true
Has column type changes: false
Compatible in ValidateLegacy mode: unknown
Unsafe actions:
RemoveNode, Path=Tables/MyEntity/Columns/MyStructure.Name
Schema hints:
Schema difference:
"./" != "./" (NodeDifference): Unknown
+Tables: "./Tables (4)" != "./Tables (4)" (NodeCollectionDifference): 1 change(s)
"./Tables/MyEntity" != "./Tables/MyEntity" (NodeDifference): Unknown
+Columns: "./Tables/MyEntity/Columns (2)" != "./Tables/MyEntity/Columns (2)" (NodeCollectionDifference): 2 change(s)
"./Tables/MyEntity/Columns/MyStructure.Name" != "" (NodeDifference): Removed
+Type: "Type: String?, Length: 4000, Native type: VarChar(4000)" != "" (ValueDifference): values differ
"" != "./Tables/MyEntity/Columns/MyStructure.NewName" (NodeDifference): Created
+Type: "" != "Type: String?, Length: 4000, Native type: VarChar(4000)" (ValueDifference): values differ
à Xtensive.Orm.Upgrade.UpgradingDomainBuilder.SynchronizeSchema(Domain domain, SchemaUpgrader upgrader, SchemaExtractor extractor, SchemaUpgradeMode schemaUpgradeMode)
Sample used:
public class MyStructure : Structure
{
[Field]
public string NewName { get; set; }
}
[Serializable]
[HierarchyRoot]
public class MyEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field]
public MyStructure MyStructure { get; set; }
public MyEntity(Session session): base(session)
{
}
}
Is this possible to do ?
What would be the right syntax ? Shall i upgrade the column names in raw sql ?
Benoit
asked
Nov 06 '14 at 10:42
Benoit Nesme
43●20●20●24