Search code examples
c#sqlitefluent-migrator

How to create SQLite FK by FluentMigrator


How I can change this code to create FK? This works without any errors and the console indicates that fk is created. But I don't see fk in the generated db...

Create.Table("Level")
.WithIdColumn()
.WithColumn("Name").AsFixedLengthString(128).NotNullable();

Create.Table("Team")
.WithIdentityIdColumn()
.WithColumn("Number").AsFixedLengthString(256).NotNullable()
.WithColumn("LevelId").AsInt32().NotNullable().ForeignKey("Level", "Id")

It also does not work although the console indicates that fk is created

Create.ForeignKey()
.FromTable("Team").ForeignColumn("LevelId")
.ToTable("Level").PrimaryColumn("Id");

Solution

  • It's reported issue https://github.com/schambers/fluentmigrator/pull/638. Waiting for the solution. Now we need to use workaround with raw sql.