migrationBuilder.CreateTable(
name: "Favourites",
columns: table => new
{
FavId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EventId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<string>(type: "varchar(127)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Favourites", x => x.FavId);
table.UniqueConstraint("AK_Favourites_EventId_UserId", x => new { x.EventId, x.UserId });
table.ForeignKey(
name: "FK_Favourites_Events_EventId",
column: x => x.EventId,
principalTable: "Events",
principalColumn: "EventId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Favourites_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
When I try to create a migration this error comes:
MySqlValueGenerationStrategy does not exist in the current context, the problem is getting solved by adding an enum similar to ( https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/master/src/EFCore.MySql/Metadata/MySqlValueGenerationStrategy.cs )
but I don't know if this solution is good or not, I need your help please?
Exception message: MySqlValueGenerationStrategy does not exist in the current context
MySQL version: 5.7
Operating system: Win10
VS2017, ASP.net CORE 2.0
Pomelo.EntityFrameworkCore.MySql version: 2.0.1
Other details about my project setup: the context is in another project.
Hi @yusufys, could you provide the full solution to us for investigating your issue? The info which you provided is not enough to repro that.
Why was this issue closed?
I am experiencing similar thing.
What is the recommended solution?\
This is the error
The name 'MySqlValueGenerationStrategy' does not existin the current context
I am same error
@smithaitufe , @SistemasSouza The solution is to install the Nuget package to your project, let's say you have Persistence layer, you have to add the project to that layer not only to your MVC project. I hope this was clear :)
thanks @yusufys it work well
Most helpful comment
@smithaitufe , @SistemasSouza The solution is to install the Nuget package to your project, let's say you have Persistence layer, you have to add the project to that layer not only to your MVC project. I hope this was clear :)