mirror of https://github.com/abpframework/abp.git
18 changed files with 155 additions and 23 deletions
@ -0,0 +1,7 @@ |
|||
<Project> |
|||
<PropertyGroup> |
|||
<LangVersion>latest</LangVersion> |
|||
<Version>1.0.0</Version> |
|||
<NoWarn>$(NoWarn);CS1591</NoWarn> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,9 @@ |
|||
namespace MyCompanyName.MyProjectName |
|||
{ |
|||
public static class MyProjectNameConsts |
|||
{ |
|||
public const string DefaultDbTablePrefix = "App"; |
|||
|
|||
public const string DefaultDbSchema = null; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
|||
using Volo.Abp.BackgroundJobs.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
|
|||
namespace MyCompanyName.MyProjectName.EntityFrameworkCore |
|||
{ |
|||
public class MyProjectNameMigrationsDbContext : AbpDbContext<MyProjectNameMigrationsDbContext> |
|||
{ |
|||
public MyProjectNameMigrationsDbContext(DbContextOptions<MyProjectNameMigrationsDbContext> options) |
|||
: base(options) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder builder) |
|||
{ |
|||
base.OnModelCreating(builder); |
|||
|
|||
builder.ConfigurePermissionManagement(); |
|||
builder.ConfigureSettingManagement(); |
|||
builder.ConfigureBackgroundJobs(); |
|||
builder.ConfigureAuditLogging(); |
|||
builder.ConfigureIdentity(); |
|||
|
|||
builder.ConfigureMyProjectName(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.IO; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
|
|||
namespace MyCompanyName.MyProjectName.EntityFrameworkCore |
|||
{ |
|||
public class MyProjectNameMigrationsDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameMigrationsDbContext> |
|||
{ |
|||
public MyProjectNameMigrationsDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
|
|||
var builder = new DbContextOptionsBuilder<MyProjectNameMigrationsDbContext>() |
|||
.UseSqlServer(configuration.GetConnectionString("Default")); |
|||
|
|||
return new MyProjectNameMigrationsDbContext(builder.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Directory.GetCurrentDirectory()) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
<RootNamespace>MyCompanyName.MyProjectName</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,34 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp; |
|||
|
|||
namespace MyCompanyName.MyProjectName.EntityFrameworkCore |
|||
{ |
|||
public static class MyProjectNameDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigureMyProjectName(this ModelBuilder builder) |
|||
{ |
|||
Check.NotNull(builder, nameof(builder)); |
|||
|
|||
var tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix; |
|||
var schema = MyProjectNameConsts.DefaultDbSchema; |
|||
|
|||
/* Configure all entities here. Example: |
|||
|
|||
builder.Entity<Question>(b => |
|||
{ |
|||
//Configure table & schema name
|
|||
//b.ToTable(tablePrefix + "Questions", schema);
|
|||
|
|||
//Properties
|
|||
//b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);
|
|||
|
|||
//Configure relations
|
|||
//b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);
|
|||
|
|||
//Configure indexes
|
|||
//b.HasIndex(q => q.CreationTime);
|
|||
}); |
|||
*/ |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue