Fluent NHibernate Schema output with errors when using list

56 views Asked by At

I have two tables which are Many-To-One mapped. However, it is important to maintain the order of the second table, so when I use automapping, Fluent automapper creates a bag. I changed this to force a list by using this command:

.Override(Of ingredients)(Function(map) map.HasMany(Function(x) x.PolygonData).AsList())

(VB.NET syntax)

So I say "AsList" and instead of using a bag, the mapping xml which gets generated contains a list now. Fine so far. However,

the statement generated cannot be handled by MySQL. I use MySQL55Dialect to create the statements and I use exactly that version. But it creates the following create:

create table `ingredients` (
    Id INTEGER NOT NULL AUTO_INCREMENT,
   Name FLOAT,
   Amout FLOAT,
   Soup_id INTEGER,
   Index INTEGER,
   primary key (Id)
)

It crashes because of the line "Index INTEGER," but I don't know what to do here. Any ideas?

Thanks!! Best, Chris

1

There are 1 answers

0
Radim Köhler On BEST ANSWER

I would suspect that Index could be a keyword for MySQL. To avoid such conflict, we can define different Index column name (sorry for C# notation)

HasMany(x => x.PolygonData)
    .AsList(idx => idx.Column("indexColumnName").Type<int>())