Can I use CustomSqlType with CompositeId?

When working with legacy tables, you need to create a CompositeId based on two char (3) fields. I don't see the overloads that make this possible with Fluent.

The mapping I'm trying is as follows:

CompositeId()
.KeyProperty(x => x.LegacyEntity1Id, "LegacyEntity1Id")
.KeyProperty(x => x.LegacyEntity2Id, "LegacyEntity2Id");

Map(x => x.LegacyEntity1Id).CustomSqlType("char(3)");
Map(x => x.LegacyEntity2Id).CustomSqlType("char(3)");

I also tried:

CompositeId()
    .KeyReference(x => x.LegacyEntity1, "LegacyEntity1Id")
    .KeyReference(x => x.LegacyEntity2, "LegacyEntity2Id");

Map(x => x.LegacyEntity1Id).CustomSqlType("char(3)");
Map(x => x.LegacyEntity2Id).CustomSqlType("char(3)");

Both results lead to the same result - the table is generated with the corresponding composite identifier, but both columns are standard nvarchar (255). As a result, foreign keys are not generated, and I get an exception, since the parent tables are char (3).

Is it impossible to display through Fluent?

If not, is there any real difference in displaying it like this: * / <>

Id(x => x.Id).GeneratedBy.Identity();

Map(x => x.LegacityEntity1Id).CustomSqlType("char(3)");
Map(x => x.LegacityEntity2Id).CustomSqlType("char(3)");

References(x => x.LegacityEntity1).Column("LegacityEntity1Id").UniqueKey("1").Not.Nullable();
References(x => x.LegacityEntity2).Column("LegacityEntity2Id").UniqueKey("1").Not.Nullable();

* (, ), ETLed SQL.

? HasManyToMany , ( ).

+1
2

KeyReference sqltype. Id(x => x.Id).Length(3).

0

2017 :

CompositeId()
  .KeyProperty(
     x => x.LegacyEntity1Id, 
     k => k.ColumnName("LegacyEntity1Id").Type("AnsiString").Length(3))
  .KeyProperty(
     x => x.LegacyEntity2Id, 
     k => k.ColumnName("LegacyEntity2Id").Type("AnsiString").Length(3))
0

All Articles