Question

I need to make a "full-text indexed" but I am using ef core 2.1 code first migration, but Full Indexes do not have first class support in core.

How can I write my own migration that would be applied while the other generated migrations are being applied?

1
2
1/16/2020 1:46:26 PM

Accepted Answer

You have to create empty migration and then in Up method you can write your SQL query.

  1. Create Empty Migration by running Add-Migration command in Package Manager Console.
  2. Add the SQL function in Up method like the following way.

public partial class your_migration_name : Migration {

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.Sql(@"<YourQuery>");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
    migrationBuilder.Sql(@"Drop <YourQuery>");
}
}
  1. Run Update-Database in Package Manager Console.
3
6/27/2018 7:25:06 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow