abp-efcorelisted
Install: claude install-skill burakdmir/abp-skills
# ABP Framework — Entity Framework Core
A guide to EF Core integration in ABP Framework v10.4. DbContext, repository, migration, eager/lazy loading.
## Trigger
- "ABP EF Core"
- "ABP DbContext"
- "ABP migration"
- "ABP repository EF"
- "ABP ConfigureByConvention"
- "ABP WithDetails"
- "ABP DbSet"
## DbContext
```csharp
public class MyDbContext : AbpDbContext<MyDbContext>
{
public DbSet<Book> Books { get; set; }
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) { }
}
```
## Entity Mapping
```csharp
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Book>(b =>
{
b.ToTable("Books");
b.ConfigureByConvention(); // REQUIRED
b.Property(x => x.Name).IsRequired().HasMaxLength(128);
});
}
```
## DbContext Registration
```csharp
context.Services.AddAbpDbContext<MyDbContext>(options =>
{
options.AddDefaultRepositories();
});
```
## DBMS Configuration
```csharp
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
options.Configure<MyOtherDbContext>(opts => opts.UseMySQL());
});
```
## Custom Repository
```csharp
public interface IBookRepository : IRepository<Book, Guid>
{
Task DeleteBooksByType(BookType type);
}
public class BookRepository : EfCoreRepository<BookStoreDbContext, Book, Guid>, IBookRepository
{
public BookRepository(IDbContextProv