efcorecolumnorder's People
efcorecolumnorder's Issues
HasColumnOrder is not respected
Hello, I tried your solution, but unfortunately it does not work.
I added the code from your project, then call the HasColumnOrder(100) on desired property in abstract class, but it is not honored.
Created migration file does not honor column order and subsequent Update-Database creates the database with same ordering..
Do you have any idea? Thanks
HasColumnOrder for EF Core 5.0 (preview 7)
Hello!
I've been trying to adapt the solution for EF Core 5, but they seem to have rearranged the internals a lot, so the old approach no longer works. The MigrationsAnnotationProvider
class/interface no longer includes the IEnumerable<IAnnotation> For(IProperty property)
method, and I'm totally lost at finding where this logic has been moved to.
For now, I've created this ugly code, which works:
public class CustomNpgsqlAnnotationProvider : NpgsqlAnnotationProvider
{
public CustomNpgsqlAnnotationProvider(RelationalAnnotationProviderDependencies dependencies)
: base(dependencies)
{
}
public override IEnumerable<IAnnotation> For(IColumn column)
{
var baseAnnotations = base.For(column);
var orderAnnotations = column
.PropertyMappings
.Select(x => x.Property.FindAnnotation(AnnotationNames.ColumnOrder))
.Where(x => x?.Value != null)
.OrderBy(x => (int)x.Value);
return baseAnnotations.Concat(orderAnnotations);
}
}
But that doesn't look too nice. So I just thought maybe you have figured this out already or something? :)
Doesn't work with MySql DB
I tried to use this with MySql DB but it didn't work. This is the error I get when I run the update:
System.InvalidOperationException: The current migration SQL generator 'CustomSqlServerMigrationsSqlGenerator' is unable to generate SQL for operations
of type 'Microsoft.EntityFrameworkCore.Migrations.Operations.MySqlCreateDatabaseOperation'.
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder
builder)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlDatabaseCreator.CreateCreateOperations()
at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlDatabaseCreator.Create()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The current migration SQL generator 'CustomSqlServerMigrationsSqlGenerator' is unable to generate SQL for operations of type 'Microsoft.EntityFrameworkCore.Migrations.Operations.MySqlCreateDatabaseOperation'.
I've done everything in the provided sample but it seems like this only support MSSQL?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.