-
Notifications
You must be signed in to change notification settings - Fork 8
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
Structural Refactoring - .NET 6.0 & SqlServer #45
Structural Refactoring - .NET 6.0 & SqlServer #45
Conversation
src/IronHook.EntityFrameworkCore.SqlServer/Migrations/20211207222118_Initial.Designer.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/Migrations/IronHookCoreDbContextModelSnapshot.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/Migrations/20211207222118_Initial.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/Migrations/IronHookCoreDbContextModelSnapshot.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/Migrations/20211207222118_Initial.Designer.cs
Show resolved
Hide resolved
Hi @codeclimate, all of problems you found are auto-generated files (migrations) 😅 |
src/IronHook.EntityFrameworkCore.PostgreSql/IronHookCoreDbContextFactory.cs
Outdated
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/IronHookCoreDbContextFactory.cs
Outdated
Show resolved
Hide resolved
Thanks for the contribution, @enisn we are reviewing it as a team. |
Update codeclimate.yml file on root and exclude SqlServer migration files. @enisn |
Codeclimate treats files with the same name as duplications. For this reason, we must make the names of the IronHookCoreDbContextFactory classes provider dependent. for example; IronHookPostgreSqlCoreDbContextFactory instead of IronHookCoreDbContextFactory |
src/IronHook.EntityFrameworkCore.PostgreSql/IronHookCoreDbContextFactory.cs
Outdated
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/IronHookCoreDbContextFactory.cs
Outdated
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.PostgreSql/IronHookCoreDbContextPostgreSqlFactory.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/IronHookCoreDbContextSqlServerFactory.cs
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.PostgreSql/Extensions/DbContextBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/IronHook.EntityFrameworkCore.SqlServer/Extensions/DbContextBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...ronHook.EntityFrameworkCore.PostgreSql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
Show resolved
Hide resolved
...nHook.EntityFrameworkCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
Show resolved
Hide resolved
…lone of IronHook.Web project
Code Climate has analyzed commit c66a794 and detected 4 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
Any updates? |
Not for now. Tests continue. PR can be merged on weekdays. @enisn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't update the wiki section, Can you update documentation too? |
I updated wiki documentation. Thanks @enisn. Developing with you is so much fun. 🎉🎉🎉🎉 |
@all-contributors please add @enisn for infrastructure, tests and code |
I've put up a pull request to add @enisn! 🎉 |
Summary
Why do you need to create DbContext and models for each EF Provider? They're just providers, the project abstraction shouldn't know anything about a provider. So I removed all the provider-specified codes and merged them into a single abstraction layer.
As I can see, migrations are managed by the library. Between EF Providers, the only different thing is migrations. Only migrations are separated in the ideal scenario. You can see, provider specified projects have only migrations but now any of EF providers can be used via generating migrations
What brings that structure?
That structure has a couple of benefits like I presented below.
Database Independency
Firstly, database dependency is completely removed. That means developers can use any database as they wish with EntityFramework. They need to manage their own migrations for database providers which we don't provide migrations.
If we provide migrations, it can be defined via calling
UseIronHook{databasename}Migrations()
method.I just replaced
UseIronHook()
method withMigrateIronHook()
method since it doesn't add a middleware, it just performs a migration operation.Migrations aren't provided by IronHook, but
MigrateIronHook
can still be used, it'll create a database from the current state of DbContext with https://github.com/FowApps/IronHook/pull/45/files#diff-48af72c016bfcfaede0f855ae54a6f1b88fceeb48b7977aea5bb3bc412f376edR41-R48Multi-Targeting
Now, the project can support both framework versions at the same time. Projects are targeting .NET 5 and .NET6 right now.
In the future, .Net 5 support can be dropped partially.
Common DbContext
I just have removed DB provider-specific DbContexes since there is no difference with CoreDbContext. Using single DbContext is much more maintainable.