Pomelo.entityframeworkcore.mysql: MySqlValueGenerationStrategy does not exist in the current context

Created on 1 Nov 2017  路  5Comments  路  Source: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

The code

       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);
                });

The issue

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

Further technical details

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.

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 :)

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ptsneves picture ptsneves  路  3Comments

hainguyenthanh picture hainguyenthanh  路  3Comments

mason-chase picture mason-chase  路  4Comments

Toemsel picture Toemsel  路  3Comments

leobert1226 picture leobert1226  路  3Comments