Module template db prefix change

pull/1904/head
Halil İbrahim Kalkan 6 years ago
parent 103532a9ea
commit 03c8e57fca

@ -1,9 +0,0 @@
namespace MyCompanyName.MyProjectName
{
public static class MyProjectNameConsts
{
public const string DefaultDbTablePrefix = "MyProjectName";
public const string DefaultDbSchema = null;
}
}

@ -0,0 +1,11 @@
namespace MyCompanyName.MyProjectName
{
public static class MyProjectNameDbProperties
{
public static string DbTablePrefix { get; } = "MyProjectName";
public static string DbSchema { get; } = null;
public const string ConnectionStringName = "MyProjectName";
}
}

@ -3,7 +3,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
[ConnectionStringName("MyProjectName")] [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameDbContext : IEfCoreDbContext public interface IMyProjectNameDbContext : IEfCoreDbContext
{ {
/* Add DbSet for each Aggregate Root here. Example: /* Add DbSet for each Aggregate Root here. Example:

@ -4,13 +4,9 @@ using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
[ConnectionStringName("MyProjectName")] [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>, IMyProjectNameDbContext public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>, IMyProjectNameDbContext
{ {
public static string TablePrefix { get; set; } = MyProjectNameConsts.DefaultDbTablePrefix;
public static string Schema { get; set; } = MyProjectNameConsts.DefaultDbSchema;
/* Add DbSet for each Aggregate Root here. Example: /* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; } * public DbSet<Question> Questions { get; set; }
*/ */
@ -25,11 +21,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
builder.ConfigureMyProjectName(options => builder.ConfigureMyProjectName();
{
options.TablePrefix = TablePrefix;
options.Schema = Schema;
});
} }
} }
} }

@ -12,7 +12,10 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
Check.NotNull(builder, nameof(builder)); Check.NotNull(builder, nameof(builder));
var options = new MyProjectNameModelBuilderConfigurationOptions(); var options = new MyProjectNameModelBuilderConfigurationOptions(
MyProjectNameDbProperties.DbTablePrefix,
MyProjectNameDbProperties.DbSchema
);
optionsAction?.Invoke(options); optionsAction?.Invoke(options);

@ -6,8 +6,8 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
public class MyProjectNameModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions public class MyProjectNameModelBuilderConfigurationOptions : ModelBuilderConfigurationOptions
{ {
public MyProjectNameModelBuilderConfigurationOptions( public MyProjectNameModelBuilderConfigurationOptions(
[NotNull] string tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix, [NotNull] string tablePrefix = "",
[CanBeNull] string schema = MyProjectNameConsts.DefaultDbSchema) [CanBeNull] string schema = null)
: base( : base(
tablePrefix, tablePrefix,
schema) schema)

@ -3,7 +3,7 @@ using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB
{ {
[ConnectionStringName("MyProjectName")] [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext
{ {
/* Define mongo collections here. Example: /* Define mongo collections here. Example:

@ -3,11 +3,9 @@ using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB
{ {
[ConnectionStringName("MyProjectName")] [ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext
{ {
public static string CollectionPrefix { get; set; } = MyProjectNameConsts.DefaultDbTablePrefix;
/* Add mongo collections here. Example: /* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>(); * public IMongoCollection<Question> Questions => Collection<Question>();
*/ */
@ -16,10 +14,7 @@ namespace MyCompanyName.MyProjectName.MongoDB
{ {
base.CreateModel(modelBuilder); base.CreateModel(modelBuilder);
modelBuilder.ConfigureMyProjectName(options => modelBuilder.ConfigureMyProjectName();
{
options.CollectionPrefix = CollectionPrefix;
});
} }
} }
} }

@ -12,7 +12,9 @@ namespace MyCompanyName.MyProjectName.MongoDB
{ {
Check.NotNull(builder, nameof(builder)); Check.NotNull(builder, nameof(builder));
var options = new MyProjectNameMongoModelBuilderConfigurationOptions(); var options = new MyProjectNameMongoModelBuilderConfigurationOptions(
MyProjectNameDbProperties.DbTablePrefix
);
optionsAction?.Invoke(options); optionsAction?.Invoke(options);
} }

@ -6,8 +6,8 @@ namespace MyCompanyName.MyProjectName.MongoDB
public class MyProjectNameMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions public class MyProjectNameMongoModelBuilderConfigurationOptions : MongoModelBuilderConfigurationOptions
{ {
public MyProjectNameMongoModelBuilderConfigurationOptions( public MyProjectNameMongoModelBuilderConfigurationOptions(
[NotNull] string tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix) [NotNull] string collectionPrefix = "")
: base(tablePrefix) : base(collectionPrefix)
{ {
} }
} }

Loading…
Cancel
Save