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

Consider to remove EntityFrameworkCore.DbMigrations project from the solution #8776

Closed
hikalkan opened this issue Apr 24, 2021 · 5 comments · Fixed by #9194
Closed

Consider to remove EntityFrameworkCore.DbMigrations project from the solution #8776

hikalkan opened this issue Apr 24, 2021 · 5 comments · Fixed by #9194

Comments

@hikalkan
Copy link
Member

hikalkan commented Apr 24, 2021

Instead of a separate migration dbcontext, we can use application's dbcontext. This simplifies database mappings and migrations, especially when you want to setup relations to entities coming from modules. I see some developers found the current structure complicated.

One disadvantage is that we should remove the AppUser in the solution and use IdentityUser entity (coming from the Identity module) when we need users in our code. So, we can't add new type-safe properties to this entity. However, module extensibility system already provides an easy way to add extra properties to existing entities.

Making that change is easy actually, but we should update all tutorials, documents, tooling, etc.

@davidzwa
Copy link

davidzwa commented Apr 29, 2021

  1. Yes its complex to separate the contexts. I do want to ask the question how does this impact non-monolithic solutions? Wasnt the reason to go for split contexts to support that better?
  2. I wonder what this Application DbContext is that you mention.
  3. Im a monolithic user, so this would be an awesome step forward as the migration towards this ABP structure basically meant we had to completely isolate from ABP's Identity tables. Not only is this a huge pain and loss, but it's my belief that it also causes new developers to shy away from ABP. Personally I am not afraid of a challenge, but I guess Im far from the only one with this experience. Let us know if you can use any help to push this forward or testing it.

@hikalkan
Copy link
Member Author

hikalkan commented May 1, 2021

Hi,

  1. Actually, it is better for non-monolith apps since they have multiple dbcontext and 2 dbcontexts for each database is worse. The reason behind the separate dbcontexts decision was to simplify and keep minimum the application's dbcontext. Also, it was providing a way to map your own entities (like AppUser) to existing tables of the depending modules (while you should carefully do it since EF Core doesn't like that much). However, it brings additional complexities as we see.
  2. This one
  3. The change is easy actually, I will handle that. I want test from you, especially about how to process for existing databases.

@hikalkan hikalkan changed the title Consider to remove EntityFramework.DbMigrations project from the solution Consider to remove EntityFrameworkCore.DbMigrations project from the solution May 17, 2021
@hikalkan
Copy link
Member Author

I've written an article to show how this can be done for existing solutions: https://community.abp.io/articles/unifying-dbcontexts-for-ef-core-removing-the-ef-core-migrations-project-nsyhrtna

@jucchytil
Copy link

When will 4.4 be released?

@jucchytil
Copy link

found it. July 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment