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
Problems rebuilding MySQL Migration for IdentityServer.EntityFrameworkCore #1920
Comments
Volo.Abp.IdentityServer has multiple fields that are out of length set to the primary key, causing the problem to be discovered e.g:
|
Some problems have arisen due to the latest source code. |
@maliming we may need to change lenghts, or re-define the PK. Can you check and write all the problems and possible solutions please? Thanks. |
The most appropriate solution is to move them out of the primary key. |
I have a temporary solution, first turn the value down to solve the problem that cannot be migrated at the moment. |
Maybe we should talk to the identity server because its EF doesn't seem to work with mysql. |
There are currently two problems in mysql: The second is the maximum length of the key column is 3072 bytes. In short, these are compatibility issues between different databases, just as the length of column names in oracle cannot exceed 30. We can customize the maximum length of index columns and varchar to be compatible with common database requirements. Maybe we should keep in sync with identity server4. If there is compatibility problem with database length, etc, developers can modify it themselves. For example, when I use oracle, I need to rename some fields. (30 or 128 depends on the database version. ) @hikalkan What do you think? |
This is my current solution add IdentityServerModelCreatingExtensions.cs public static class IdentityServerModelCreatingExtensions
{
public static void ConfigureIdentityServerForGaea (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 ?
});
}
} change MigrationsDbContext.cs builder.ConfigureGaea();
builder.ConfigureIdentityServerForGaea(); // add |
@Y2zz I suppose this is the most proper solution to this problem, you arrange columns based on the DBMS you're using. Based on your solution, I will create a built-in way of it. |
I've implemented it via 647b863 Usage: builder.ConfigureIdentityServer(options =>
{
options.DatabaseProvider = EfCoreDatabaseProvider.MySql;
}); Do this on your Migration DbContext. |
I think this way deviates from my original intention. |
@hikalkan If so, it means that we need to make special configurations for possible database providers in the module. Although some providers are not required to be configured by default. I think we shouldn't do it, we should give it to the developer to handle it. Depends on the database used by the developer. If a module may not be compatible with a database, the module should explain it and provide a solution. |
Just making for exceptional cases. In the implementation, it only checks MySql for a few places. In the future, we may add some exceptions for other databases if needed.
In general, I agree on this idea. However, if we don't implement it out of the box, then we will provide documentation for it and every developer will repeat it in their code or create another issue on GitHub to ask it to us. I don't intent to solve all provider issues which is not possible. But, for example if one developer has problems with X provider, creates an issue and shows the solution then we can add it to the module so everyone can use easily. Module configures its own database mapping, so being compatible to different databases is a plus. |
I used the code change as below: //builder.ConfigureIdentityServer();
builder.ConfigureIdentityServer(options => {`
options.DatabaseProvider = EfCoreDatabaseProvider.Oracle;
}); The issue #2704 still reproduce it. :( |
@jack-gaojz |
Yes, that's my honor. I will do it. Thanks. :) |
Which namespace is |
Thanks @hikalkan and @maliming for the given temporary solutions. However, I think this issue should be open to make it noticeable and to prevent the upcoming duplicated issues, until some best-practices would be written in the documentation as it was mentioned:
|
if you have a an existing project with Migrations and you want to convert it to Oracle then you need to delete the Migrations folder to make it work. Because the existing migrations were created based on your previous database provider. I wrote this because some people fall into this trap. |
The text was updated successfully, but these errors were encountered: