Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget Volo.Abp.EntityFrameworkCore.MySQL package? #2053

Closed
halida opened this issue Oct 31, 2019 · 16 comments
Closed

nuget Volo.Abp.EntityFrameworkCore.MySQL package? #2053

halida opened this issue Oct 31, 2019 · 16 comments
Labels

Comments

@halida
Copy link

@halida halida commented Oct 31, 2019

Hi, I'm trying to use MySQL, but I did not found Volo.Abp.EntityFrameworkCore.MySQL package, will you release it?

My dotnet version: .NET Core 3.0

@maliming

This comment has been minimized.

@halida

This comment has been minimized.

Copy link
Author

@halida halida commented Oct 31, 2019

@maliming Thanks, when will it support .NET Core 3.0?

@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Oct 31, 2019

@maliming maliming closed this Oct 31, 2019
@halida

This comment has been minimized.

Copy link
Author

@halida halida commented Oct 31, 2019

@maliming But on the nuget page above, it only shows: .NETStandard 2.1, and I cannot found the package, do you need some change on it?

@yekalkan yekalkan added the question label Oct 31, 2019
@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

with the package <PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="1.0.2" />
when update-database , it occurs the critical erros as follow:
BLOB/TEXT column 'Value' used in key specification without a key length.

Failed executing DbCommand (22ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE `IdentityServerApiSecrets` (
    `Type` varchar(250) NOT NULL,
    `Value` longtext NOT NULL,
    `ApiResourceId` char(36) NOT NULL,
    `Description` varchar(2000) NULL,
    `Expiration` datetime(6) NULL,
    CONSTRAINT `PK_IdentityServerApiSecrets` PRIMARY KEY (`ApiResourceId`, `Type`, `Value`),
    CONSTRAINT `FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResou~` FOREIGN KEY (`ApiResourceId`) REFERENCES `IdentityServerApiResources` (`Id`) ON DELETE CASCADE
);
MySql.Data.MySqlClient.MySqlException (0x80004005): BLOB/TEXT column 'Value' used in key specification without a key length

It just happens via the standard abp-cli generated projects. @maliming @yekalkan

@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

@maliming

i referrenced the solution, it still couldn't work.
#1920 (comment)
it still reports the same error, i think you can reproduce the same error.

@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

Recreate the migration.

@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

yeah, i deleted the old migration and the database, then Recreate the migration..
the failed report still keep the same

Failed executing DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE `IdentityServerApiSecrets` (
    `Type` varchar(250) NOT NULL,
    `Value` longtext NOT NULL,
    `ApiResourceId` char(36) NOT NULL,
    `Description` varchar(2000) NULL,
    `Expiration` datetime(6) NULL,
    CONSTRAINT `PK_IdentityServerApiSecrets` PRIMARY KEY (`ApiResourceId`, `Type`, `Value`),
    CONSTRAINT `FK_IdentityServerApiSecrets_IdentityServerApiResources_ApiResou~` FOREIGN KEY (`ApiResourceId`) REFERENCES `IdentityServerApiResources` (`Id`) ON DELETE CASCADE
);
MySql.Data.MySqlClient.MySqlException (0x80004005): BLOB/TEXT column 'Value' used in key specification without a key length
 ---> MySql.Data.MySqlClient.MySqlException (0x80004005): BLOB/TEXT column 'Value' used in key specification without a key length

i used the codes as follow

public static class IdentityServerModelCreatingExtensions
    {
        public static void ConfigureIdentityServerForMySQL(this ModelBuilder builder)
        {
            // Solve the problem of MySQL migration
            // https://github.com/abpframework/abp/issues/1920

            builder.Entity<ApiSecret>(b =>
            {
                // After trying, you can also set it to 400
                b.Property(x => x.Value).HasMaxLength(300);
            });

            builder.Entity<ClientPostLogoutRedirectUri>(b =>
            {
                b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300); // or 400 ?
            });

            builder.Entity<ClientRedirectUri>(b =>
            {
                b.Property(x => x.RedirectUri).HasMaxLength(300); // or 400 ?
            });

            builder.Entity<ClientSecret>(b =>
            {
                b.Property(x => x.Value).HasMaxLength(300); // or 400 ?
            });
            
        }
    }

and in the migration dbcontext, i repairt it.

protected override void OnModelCreating(ModelBuilder builder)
        {
base.OnModelCreating(builder);
// ...

// ....
//            builder.ConfigureIdentityServer(options =>
//            {
//                options.DatabaseProvider = EfCoreDatabaseProvider.MySql;  // no worked effect
//            });
builder.ConfigureIdentityServerForMySQL(); // no work effect

}
@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

The OnModelCreating method needs to call the OnModelCreating of the base class.
base.OnModelCreating(modelBuilder);

@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

The OnModelCreating method needs to call the OnModelCreating of the base class.
base.OnModelCreating(modelBuilder);

that's right; sorry for the codes ignored in the previous comment; i amend the last comment.
it still could not work.

i think you could use the abp-cli tool to reproduce the same problem on version 1.0.2

@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

Can you provide a project to reproduce the problem?

@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

Can you provide a project to reproduce the problem?

ok, i pushed the below demo project generated by abp-cli tool @maliming
https://github.com/johnnba/simpleAbpNextMysqlDemo.git

it's really thanksful for your time to check and fix the mysql update-database problem

@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

@johnnba

This comment has been minimized.

Copy link

@johnnba johnnba commented Nov 1, 2019

it's great that the code worked finally , thanks a lot. @maliming
it was amazing that the same codes in DbContextModelCreatingExtensions worked rather than OnModelCreating functions.
i'm still puzzled .

johnnba added a commit to johnnba/simpleAbpNextMysqlDemo that referenced this issue Nov 1, 2019
@maliming

This comment has been minimized.

Copy link
Member

@maliming maliming commented Nov 1, 2019

johnnba added a commit to johnnba/simpleAbpNextMysqlDemo that referenced this issue Nov 1, 2019
fix the mysql issue
abpframework/abp#2053

nuget Volo.Abp.EntityFrameworkCore.MySQL package

resolve the update-database problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.