Added comments for EF core layer.

pull/1148/head
Halil ibrahim Kalkan 6 years ago
parent 570b604ee6
commit e2f004d390

@ -11,6 +11,11 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{
/* This DbContext is only used for database migrations.
* It is not used on runtime. See MyProjectNameDbContext for the runtime DbContext.
* It is a unified model that includes configuration for
* all used modules and your application.
*/
public class MyProjectNameMigrationsDbContext : AbpDbContext<MyProjectNameMigrationsDbContext>
{
public MyProjectNameMigrationsDbContext(DbContextOptions<MyProjectNameMigrationsDbContext> options)

@ -5,6 +5,8 @@ using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{
/* This class is needed for EF Core console commands
* (like Add-Migration and Update-Database commands) */
public class MyProjectNameMigrationsDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameMigrationsDbContext>
{
public MyProjectNameMigrationsDbContext CreateDbContext(string[] args)

@ -7,11 +7,24 @@ using Volo.Abp.Users.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{
/* This is your actual DbContext used on runtime.
* It includes only your entities.
* It does not include entities of the used modules, because each module has already
* its own DbContext class. If you want to share some database tables with the used modules,
* just create a structure like done for AppUser.
*
* Don't use this DbContext for database migrations since it does not contain tables of the
* used modules (as explained above). See MyProjectNameMigrationsDbContext for migrations.
*/
[ConnectionStringName("Default")]
public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>
{
public DbSet<AppUser> Users { get; set; }
/* Add DbSet properties for your Aggregate Roots / Entities here.
* Also map them inside MyProjectNameDbContextModelCreatingExtensions.ConfigureMyProjectName
*/
public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options)
: base(options)
{

@ -30,13 +30,14 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
context.Services.AddAbpDbContext<MyProjectNameDbContext>(options =>
{
/* Remove "includeAllEntities: true" to create
* default repositories only for aggregate roots
*/
* default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true);
});
Configure<AbpDbContextOptions>(options =>
{
/* The main point to change your DBMS.
* See also MyProjectNameMigrationsDbContextFactory for EF Core tooling. */
options.UseSqlServer();
});
}

Loading…
Cancel
Save