Merge pull request #9194 from abpframework/maliming/Fallback-to-the-EntityFrameworkCore

Remove EntityFrameworkCore.DbMigrations project from the solution & Compatible with CLI.
pull/9116/head
Halil İbrahim Kalkan 4 years ago committed by GitHub
commit b6a4e4306b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,7 @@ using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using NuGet.Versioning;
using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Licensing; using Volo.Abp.Cli.Licensing;
using Volo.Abp.Cli.ProjectBuilding.Analyticses; using Volo.Abp.Cli.ProjectBuilding.Analyticses;
@ -111,6 +112,11 @@ namespace Volo.Abp.Cli.ProjectBuilding
args args
); );
if (context.Template is AppTemplateBase appTemplateBase)
{
appTemplateBase.HasDbMigrations = SemanticVersion.Parse(templateFile.Version) < new SemanticVersion(4, 3, 99);
}
TemplateProjectBuildPipelineBuilder.Build(context).Execute(); TemplateProjectBuildPipelineBuilder.Build(context).Execute();
if (!templateInfo.DocumentUrl.IsNullOrEmpty()) if (!templateInfo.DocumentUrl.IsNullOrEmpty())

@ -9,9 +9,12 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
{ {
public abstract class AppTemplateBase : TemplateInfo public abstract class AppTemplateBase : TemplateInfo
{ {
public bool HasDbMigrations { get; set; }
protected AppTemplateBase(string templateName) protected AppTemplateBase(string templateName)
: base(templateName, DatabaseProvider.EntityFrameworkCore, UiFramework.Mvc) : base(templateName, DatabaseProvider.EntityFrameworkCore, UiFramework.Mvc)
{ {
} }
public static bool IsAppTemplate(string templateName) public static bool IsAppTemplate(string templateName)
@ -40,31 +43,54 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
return steps; return steps;
} }
private static void ConfigureTenantSchema(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) private void ConfigureTenantSchema(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps)
{ {
if (context.BuildArgs.ExtraProperties.ContainsKey("separate-tenant-schema")) if (context.BuildArgs.ExtraProperties.ContainsKey("separate-tenant-schema"))
{ {
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); if (HasDbMigrations)
steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.EntityFrameworkCore.SeparateDbMigrations", "MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); {
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations"));
steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.EntityFrameworkCore.SeparateDbMigrations", "MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations"));
}
else
{
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore"));
steps.Add(new TemplateProjectRenameStep("MyCompanyName.MyProjectName.EntityFrameworkCoreWithSeparateDbContext", "MyCompanyName.MyProjectName.EntityFrameworkCore"));
}
} }
else else
{ {
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.SeparateDbMigrations")); if (HasDbMigrations)
{
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.SeparateDbMigrations"));
}
else
{
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCoreWithSeparateDbContext"));
}
} }
} }
private static void SwitchDatabaseProvider(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) private void SwitchDatabaseProvider(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps)
{ {
if (context.BuildArgs.DatabaseProvider == DatabaseProvider.MongoDb) if (context.BuildArgs.DatabaseProvider == DatabaseProvider.MongoDb)
{ {
steps.Add(new AppTemplateSwitchEntityFrameworkCoreToMongoDbStep()); steps.Add(new AppTemplateSwitchEntityFrameworkCoreToMongoDbStep(HasDbMigrations));
} }
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore) if (context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore)
{ {
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore")); if (HasDbMigrations)
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); {
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests"));
}
else
{
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests"));
}
} }
else else
{ {
@ -380,13 +406,21 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
steps.Add(new UpdateNuGetConfigStep("/aspnet-core/NuGet.Config")); steps.Add(new UpdateNuGetConfigStep("/aspnet-core/NuGet.Config"));
} }
private static void RemoveMigrations(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) private void RemoveMigrations(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps)
{ {
if (string.IsNullOrWhiteSpace(context.BuildArgs.Version) || if (string.IsNullOrWhiteSpace(context.BuildArgs.Version) ||
SemanticVersion.Parse(context.BuildArgs.Version) > new SemanticVersion(4,1,99)) SemanticVersion.Parse(context.BuildArgs.Version) > new SemanticVersion(4,1,99))
{ {
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations")); if (HasDbMigrations)
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/TenantMigrations")); {
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations"));
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/TenantMigrations"));
}
else
{
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations"));
steps.Add(new RemoveFolderStep("/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/TenantMigrations"));
}
} }
} }

@ -1,12 +1,17 @@
using System; using System;
using System.Linq;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.Cli.ProjectBuilding.Building;
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
{ {
public class AppTemplateSwitchEntityFrameworkCoreToMongoDbStep : ProjectBuildPipelineStep public class AppTemplateSwitchEntityFrameworkCoreToMongoDbStep : ProjectBuildPipelineStep
{ {
private readonly bool _hasDbMigrations;
public AppTemplateSwitchEntityFrameworkCoreToMongoDbStep(bool hasDbMigrations)
{
_hasDbMigrations = hasDbMigrations;
}
public override void Execute(ProjectBuildContext context) public override void Execute(ProjectBuildContext context)
{ {
//MyCompanyName.MyProjectName.Web //MyCompanyName.MyProjectName.Web
@ -14,7 +19,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -23,7 +28,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -37,7 +42,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -46,7 +51,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -60,7 +65,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -69,7 +74,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -83,7 +88,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyCompanyName.MyProjectName.Blazor.Server.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -92,7 +97,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -106,7 +111,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -115,7 +120,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -129,7 +134,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyCompanyName.MyProjectName.DbMigrator.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyCompanyName.MyProjectName.DbMigrator.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -138,7 +143,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );
@ -201,7 +206,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
ChangeProjectReference( ChangeProjectReference(
context, context,
"/aspnet-core/src/MyCompanyName.MyProjectName.Web.Public/MyCompanyName.MyProjectName.Web.Public.csproj", "/aspnet-core/src/MyCompanyName.MyProjectName.Web.Public/MyCompanyName.MyProjectName.Web.Public.csproj",
"EntityFrameworkCore.DbMigrations", _hasDbMigrations ? "EntityFrameworkCore.DbMigrations" : "EntityFrameworkCore",
"MongoDB" "MongoDB"
); );
@ -210,7 +215,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
"/aspnet-core/src/MyCompanyName.MyProjectName.Web.Public/MyProjectNameWebPublicModule.cs", "/aspnet-core/src/MyCompanyName.MyProjectName.Web.Public/MyProjectNameWebPublicModule.cs",
"MyCompanyName.MyProjectName.EntityFrameworkCore", "MyCompanyName.MyProjectName.EntityFrameworkCore",
"MyCompanyName.MyProjectName.MongoDB", "MyCompanyName.MyProjectName.MongoDB",
"MyProjectNameEntityFrameworkCoreDbMigrationsModule", _hasDbMigrations ? "MyProjectNameEntityFrameworkCoreDbMigrationsModule" : "MyProjectNameEntityFrameworkCoreModule",
"MyProjectNameMongoDbModule" "MyProjectNameMongoDbModule"
); );

@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.MongoDB", "src\MyCompanyName.MyProjectName.MongoDB\MyCompanyName.MyProjectName.MongoDB.csproj", "{E3444355-D47E-431E-BDD0-DD3A7113B2AE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.MongoDB", "src\MyCompanyName.MyProjectName.MongoDB\MyCompanyName.MyProjectName.MongoDB.csproj", "{E3444355-D47E-431E-BDD0-DD3A7113B2AE}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations", "src\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj", "{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.Domain.Shared", "src\MyCompanyName.MyProjectName.Domain.Shared\MyCompanyName.MyProjectName.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.Domain.Shared", "src\MyCompanyName.MyProjectName.Domain.Shared\MyCompanyName.MyProjectName.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.Application.Contracts", "src\MyCompanyName.MyProjectName.Application.Contracts\MyCompanyName.MyProjectName.Application.Contracts.csproj", "{520659C8-C734-4298-A3DA-B539DB9DFC0B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.Application.Contracts", "src\MyCompanyName.MyProjectName.Application.Contracts\MyCompanyName.MyProjectName.Application.Contracts.csproj", "{520659C8-C734-4298-A3DA-B539DB9DFC0B}"
@ -91,10 +89,6 @@ Global
{E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.Build.0 = Release|Any CPU {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.Build.0 = Release|Any CPU
{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Release|Any CPU.Build.0 = Release|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.Build.0 = Debug|Any CPU {42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.ActiveCfg = Release|Any CPU {42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -175,7 +169,6 @@ Global
{50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{5F1B28C6-8D0C-4155-92D0-252F7EA5F674} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {5F1B28C6-8D0C-4155-92D0-252F7EA5F674} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{E3444355-D47E-431E-BDD0-DD3A7113B2AE} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {E3444355-D47E-431E-BDD0-DD3A7113B2AE} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{42F719ED-8413-4895-B5B4-5AB56079BC66} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {42F719ED-8413-4895-B5B4-5AB56079BC66} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}

@ -23,7 +23,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" />

@ -46,7 +46,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Server
{ {
[DependsOn( [DependsOn(
typeof(MyProjectNameApplicationModule), typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameHttpApiModule), typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule), typeof(AbpAutofacModule),

@ -26,7 +26,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application.Contracts\MyCompanyName.MyProjectName.Application.Contracts.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application.Contracts\MyCompanyName.MyProjectName.Application.Contracts.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -7,7 +7,7 @@ namespace MyCompanyName.MyProjectName.DbMigrator
{ {
[DependsOn( [DependsOn(
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameApplicationContractsModule) typeof(MyProjectNameApplicationContractsModule)
)] )]
public class MyProjectNameDbMigratorModule : AbpModule public class MyProjectNameDbMigratorModule : AbpModule

@ -144,14 +144,14 @@ namespace MyCompanyName.MyProjectName.Data
private bool DbMigrationsProjectExists() private bool DbMigrationsProjectExists()
{ {
var dbMigrationsProjectFolder = GetDbMigrationsProjectFolderPath(); var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
return dbMigrationsProjectFolder != null; return dbMigrationsProjectFolder != null;
} }
private bool MigrationsFolderExists() private bool MigrationsFolderExists()
{ {
var dbMigrationsProjectFolder = GetDbMigrationsProjectFolderPath(); var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
} }
@ -175,7 +175,7 @@ namespace MyCompanyName.MyProjectName.Data
} }
var procStartInfo = new ProcessStartInfo(fileName, var procStartInfo = new ProcessStartInfo(fileName,
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetDbMigrationsProjectFolderPath()}\"\"" $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\""
); );
try try
@ -188,7 +188,7 @@ namespace MyCompanyName.MyProjectName.Data
} }
} }
private string GetDbMigrationsProjectFolderPath() private string GetEntityFrameworkCoreProjectFolderPath()
{ {
var slnDirectoryPath = GetSolutionDirectoryPath(); var slnDirectoryPath = GetSolutionDirectoryPath();
@ -200,7 +200,7 @@ namespace MyCompanyName.MyProjectName.Data
var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src");
return Directory.GetDirectories(srcDirectoryPath) return Directory.GetDirectories(srcDirectoryPath)
.FirstOrDefault(d => d.EndsWith(".DbMigrations")); .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore"));
} }
private string GetSolutionDirectoryPath() private string GetSolutionDirectoryPath()

@ -1,63 +0,0 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Users
{
/* This entity shares the same table/collection ("AbpUsers" by default) with the
* IdentityUser entity of the Identity module.
*
* - You can define your custom properties into this class.
* - You never create or delete this entity, because it is Identity module's job.
* - You can query users from database with this entity.
* - You can update values of your custom properties.
*/
public class AppUser : FullAuditedAggregateRoot<Guid>, IUser
{
#region Base properties
/* These properties are shared with the IdentityUser entity of the Identity module.
* Do not change these properties through this class. Instead, use Identity module
* services (like IdentityUserManager) to change them.
* So, this properties are designed as read only!
*/
public virtual Guid? TenantId { get; private set; }
public virtual string UserName { get; private set; }
public virtual string Name { get; private set; }
public virtual string Surname { get; private set; }
public virtual string Email { get; private set; }
public virtual bool EmailConfirmed { get; private set; }
public virtual string PhoneNumber { get; private set; }
public virtual bool PhoneNumberConfirmed { get; private set; }
#endregion
/* Add your own properties here. Example:
*
* public string MyProperty { get; set; }
*
* If you add a property and using the EF Core, remember these;
*
* 1. Update MyProjectNameDbContext.OnModelCreating
* to configure the mapping for your new property
* 2. Update MyProjectNameEfCoreEntityExtensionMappings to extend the IdentityUser entity
* and add your new property to the migration.
* 3. Use the Add-Migration to add a new database migration.
* 4. Run the .DbMigrator project (or use the Update-Database command) to apply
* schema change to the database.
*/
private AppUser()
{
}
}
}

@ -1,16 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{
[DependsOn(
typeof(MyProjectNameEntityFrameworkCoreModule)
)]
public class MyProjectNameEntityFrameworkCoreDbMigrationsModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyProjectNameMigrationsDbContext>();
}
}
}

@ -1,48 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
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)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
/* Include modules to your migration db context */
builder.ConfigurePermissionManagement();
builder.ConfigureSettingManagement();
builder.ConfigureBackgroundJobs();
builder.ConfigureAuditLogging();
builder.ConfigureIdentity();
builder.ConfigureIdentityServer();
builder.ConfigureFeatureManagement();
builder.ConfigureTenantManagement();
/* Configure your own tables/entities inside the ConfigureMyProjectName method */
builder.ConfigureMyProjectName();
}
}
}

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>MyCompanyName.MyProjectName</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

@ -20,14 +20,14 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
public async Task MigrateAsync() public async Task MigrateAsync()
{ {
/* We intentionally resolving the MyProjectNameMigrationsDbContext /* We intentionally resolving the MyProjectNameDbContext
* from IServiceProvider (instead of directly injecting it) * from IServiceProvider (instead of directly injecting it)
* to properly get the connection string of the current tenant in the * to properly get the connection string of the current tenant in the
* current scope. * current scope.
*/ */
await _serviceProvider await _serviceProvider
.GetRequiredService<MyProjectNameMigrationsDbContext>() .GetRequiredService<MyProjectNameDbContext>()
.Database .Database
.MigrateAsync(); .MigrateAsync();
} }

@ -1,29 +1,21 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using MyCompanyName.MyProjectName.Users; using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Identity; using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Users.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.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")] [ConnectionStringName("Default")]
public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext> public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>
{ {
public DbSet<AppUser> Users { get; set; }
/* Add DbSet properties for your Aggregate Roots / Entities here. /* Add DbSet properties for your Aggregate Roots / Entities here.
* Also map them inside MyProjectNameDbContextModelCreatingExtensions.ConfigureMyProjectName
*/ */
public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options) public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options)
@ -36,23 +28,25 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
/* Configure the shared tables (with included modules) here */ /* Include modules to your migration db context */
builder.Entity<AppUser>(b => builder.ConfigurePermissionManagement();
{ builder.ConfigureSettingManagement();
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users"); //Sharing the same table "AbpUsers" with the IdentityUser builder.ConfigureBackgroundJobs();
builder.ConfigureAuditLogging();
b.ConfigureByConvention(); builder.ConfigureIdentity();
b.ConfigureAbpUser(); builder.ConfigureIdentityServer();
builder.ConfigureFeatureManagement();
/* Configure mappings for your additional properties builder.ConfigureTenantManagement();
* Also see the MyProjectNameEfCoreEntityExtensionMappings class
*/ /* Configure your own tables/entities inside here */
});
//builder.Entity<YourEntity>(b =>
/* Configure your own tables/entities inside the ConfigureMyProjectName method */ //{
// b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema);
builder.ConfigureMyProjectName(); // b.ConfigureByConvention(); //auto configure for the base class props
// //...
//});
} }
} }
} }

@ -7,18 +7,18 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
/* This class is needed for EF Core console commands /* This class is needed for EF Core console commands
* (like Add-Migration and Update-Database commands) */ * (like Add-Migration and Update-Database commands) */
public class MyProjectNameMigrationsDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameMigrationsDbContext> public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext>
{ {
public MyProjectNameMigrationsDbContext CreateDbContext(string[] args) public MyProjectNameDbContext CreateDbContext(string[] args)
{ {
MyProjectNameEfCoreEntityExtensionMappings.Configure(); MyProjectNameEfCoreEntityExtensionMappings.Configure();
var configuration = BuildConfiguration(); var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<MyProjectNameMigrationsDbContext>() var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default")); .UseSqlServer(configuration.GetConnectionString("Default"));
return new MyProjectNameMigrationsDbContext(builder.Options); return new MyProjectNameDbContext(builder.Options);
} }
private static IConfigurationRoot BuildConfiguration() private static IConfigurationRoot BuildConfiguration()

@ -1,22 +0,0 @@
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));
/* Configure your own tables/entities inside here */
//builder.Entity<YourEntity>(b =>
//{
// b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema);
// b.ConfigureByConvention(); //auto configure for the base class props
// //...
//});
}
}
}

@ -10,8 +10,8 @@ using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.Migrations namespace MyCompanyName.MyProjectName.Migrations
{ {
[DbContext(typeof(MyProjectNameMigrationsDbContext))] [DbContext(typeof(MyProjectNameDbContext))]
[Migration("20210324094537_Initial")] [Migration("20210531084225_Initial")]
partial class Initial partial class Initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -20,7 +20,7 @@ namespace MyCompanyName.MyProjectName.Migrations
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.4") .HasAnnotation("ProductVersion", "5.0.6")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>

@ -9,8 +9,8 @@ using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.Migrations namespace MyCompanyName.MyProjectName.Migrations
{ {
[DbContext(typeof(MyProjectNameMigrationsDbContext))] [DbContext(typeof(MyProjectNameDbContext))]
partial class MyProjectNameMigrationsDbContextModelSnapshot : ModelSnapshot partial class MyProjectNameDbContextModelSnapshot : ModelSnapshot
{ {
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
@ -18,7 +18,7 @@ namespace MyCompanyName.MyProjectName.Migrations
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.4") .HasAnnotation("ProductVersion", "5.0.6")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>

@ -20,4 +20,11 @@
<ProjectReference Include="..\..\..\..\..\modules\feature-management\src\Volo.Abp.FeatureManagement.EntityFrameworkCore\Volo.Abp.FeatureManagement.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\feature-management\src\Volo.Abp.FeatureManagement.EntityFrameworkCore\Volo.Abp.FeatureManagement.EntityFrameworkCore.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.*">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> </Project>

@ -23,7 +23,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" />
</ItemGroup> </ItemGroup>

@ -35,7 +35,7 @@ namespace MyCompanyName.MyProjectName
typeof(AbpCachingStackExchangeRedisModule), typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(MyProjectNameApplicationModule), typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule), typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule) typeof(AbpSwashbuckleModule)
)] )]

@ -23,7 +23,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" />
</ItemGroup> </ItemGroup>

@ -36,7 +36,7 @@ namespace MyCompanyName.MyProjectName
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpAspNetCoreMultiTenancyModule),
typeof(MyProjectNameApplicationModule), typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAccountWebIdentityServerModule), typeof(AbpAccountWebIdentityServerModule),

@ -44,7 +44,7 @@
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -40,7 +40,7 @@ namespace MyCompanyName.MyProjectName
typeof(AbpAccountWebIdentityServerModule), typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule), typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule) typeof(AbpAspNetCoreSerilogModule)
)] )]
public class MyProjectNameIdentityServerModule : AbpModule public class MyProjectNameIdentityServerModule : AbpModule

@ -1,6 +1,4 @@
using MongoDB.Driver; using Volo.Abp.Data;
using MyCompanyName.MyProjectName.Users;
using Volo.Abp.Data;
using Volo.Abp.MongoDB; using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB namespace MyCompanyName.MyProjectName.MongoDB
@ -8,18 +6,18 @@ namespace MyCompanyName.MyProjectName.MongoDB
[ConnectionStringName("Default")] [ConnectionStringName("Default")]
public class MyProjectNameMongoDbContext : AbpMongoDbContext public class MyProjectNameMongoDbContext : AbpMongoDbContext
{ {
public IMongoCollection<AppUser> Users => Collection<AppUser>(); /* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>();
*/
protected override void CreateModel(IMongoModelBuilder modelBuilder) protected override void CreateModel(IMongoModelBuilder modelBuilder)
{ {
base.CreateModel(modelBuilder); base.CreateModel(modelBuilder);
modelBuilder.Entity<AppUser>(b => //builder.Entity<YourEntity>(b =>
{ //{
/* Sharing the same "AbpUsers" collection // //...
* with the Identity module's IdentityUser class. */ //});
b.CollectionName = "AbpUsers";
});
} }
} }
} }

@ -39,7 +39,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" />

@ -43,7 +43,7 @@ namespace MyCompanyName.MyProjectName.Web
[DependsOn( [DependsOn(
typeof(MyProjectNameHttpApiModule), typeof(MyProjectNameHttpApiModule),
typeof(MyProjectNameApplicationModule), typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpIdentityWebModule), typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule), typeof(AbpSettingManagementWebModule),

@ -11,7 +11,7 @@ using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore namespace MyCompanyName.MyProjectName.EntityFrameworkCore
{ {
[DependsOn( [DependsOn(
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule), typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameTestBaseModule), typeof(MyProjectNameTestBaseModule),
typeof(AbpEntityFrameworkCoreSqliteModule) typeof(AbpEntityFrameworkCoreSqliteModule)
)] )]
@ -47,11 +47,11 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore
var connection = new SqliteConnection("Data Source=:memory:"); var connection = new SqliteConnection("Data Source=:memory:");
connection.Open(); connection.Open();
var options = new DbContextOptionsBuilder<MyProjectNameMigrationsDbContext>() var options = new DbContextOptionsBuilder<MyProjectNameDbContext>()
.UseSqlite(connection) .UseSqlite(connection)
.Options; .Options;
using (var context = new MyProjectNameMigrationsDbContext(options)) using (var context = new MyProjectNameDbContext(options))
{ {
context.GetService<IRelationalDatabaseCreator>().CreateTables(); context.GetService<IRelationalDatabaseCreator>().CreateTables();
} }

@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using MyCompanyName.MyProjectName.Users;
using Shouldly; using Shouldly;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Xunit; using Xunit;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples
@ -17,11 +17,11 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples
[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] [Collection(MyProjectNameTestConsts.CollectionDefinitionName)]
public class SampleRepositoryTests : MyProjectNameEntityFrameworkCoreTestBase public class SampleRepositoryTests : MyProjectNameEntityFrameworkCoreTestBase
{ {
private readonly IRepository<AppUser, Guid> _appUserRepository; private readonly IRepository<IdentityUser, Guid> _appUserRepository;
public SampleRepositoryTests() public SampleRepositoryTests()
{ {
_appUserRepository = GetRequiredService<IRepository<AppUser, Guid>>(); _appUserRepository = GetRequiredService<IRepository<IdentityUser, Guid>>();
} }
[Fact] [Fact]

@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\..\src\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.TestBase\MyCompanyName.MyProjectName.TestBase.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.TestBase\MyCompanyName.MyProjectName.TestBase.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" />
</ItemGroup> </ItemGroup>

@ -1,9 +1,9 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using MyCompanyName.MyProjectName.Users;
using MongoDB.Driver.Linq; using MongoDB.Driver.Linq;
using Shouldly; using Shouldly;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Xunit; using Xunit;
namespace MyCompanyName.MyProjectName.MongoDB.Samples namespace MyCompanyName.MyProjectName.MongoDB.Samples
@ -16,11 +16,11 @@ namespace MyCompanyName.MyProjectName.MongoDB.Samples
[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] [Collection(MyProjectNameTestConsts.CollectionDefinitionName)]
public class SampleRepositoryTests : MyProjectNameMongoDbTestBase public class SampleRepositoryTests : MyProjectNameMongoDbTestBase
{ {
private readonly IRepository<AppUser, Guid> _appUserRepository; private readonly IRepository<IdentityUser, Guid> _appUserRepository;
public SampleRepositoryTests() public SampleRepositoryTests()
{ {
_appUserRepository = GetRequiredService<IRepository<AppUser, Guid>>(); _appUserRepository = GetRequiredService<IRepository<IdentityUser, Guid>>();
} }
[Fact] [Fact]

Loading…
Cancel
Save