diff --git a/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.Designer.cs b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.Designer.cs
new file mode 100644
index 0000000000..142e1c79d5
--- /dev/null
+++ b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.Designer.cs
@@ -0,0 +1,113 @@
+//
+using AbpDesk.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.EntityFrameworkCore.Storage.Internal;
+using System;
+
+namespace AbpDesk.EntityFrameworkCore.Migrations
+{
+ [DbContext(typeof(AbpDeskDbContext))]
+ [Migration("20180218143334_Made_Permission_Entity_MultiTenant")]
+ partial class Made_Permission_Entity_MultiTenant
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.0.1-rtm-125")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("AbpDesk.Tickets.Ticket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Body")
+ .HasMaxLength(65536);
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(256);
+
+ b.HasKey("Id");
+
+ b.ToTable("DskTickets");
+ });
+
+ modelBuilder.Entity("Volo.Abp.MultiTenancy.Tenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("MtTenants");
+ });
+
+ modelBuilder.Entity("Volo.Abp.MultiTenancy.TenantConnectionString", b =>
+ {
+ b.Property("TenantId");
+
+ b.Property("Name")
+ .HasMaxLength(128);
+
+ b.Property("Value")
+ .IsRequired()
+ .HasMaxLength(1024);
+
+ b.HasKey("TenantId", "Name");
+
+ b.ToTable("MtTenantConnectionStrings");
+ });
+
+ modelBuilder.Entity("Volo.Abp.Permissions.PermissionGrant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128);
+
+ b.Property("ProviderKey")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("ProviderName")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("TenantId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name", "ProviderName", "ProviderKey");
+
+ b.ToTable("AbpPermissionGrants");
+ });
+
+ modelBuilder.Entity("Volo.Abp.MultiTenancy.TenantConnectionString", b =>
+ {
+ b.HasOne("Volo.Abp.MultiTenancy.Tenant")
+ .WithMany("ConnectionStrings")
+ .HasForeignKey("TenantId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.cs b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.cs
new file mode 100644
index 0000000000..c641ec0eda
--- /dev/null
+++ b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/20180218143334_Made_Permission_Entity_MultiTenant.cs
@@ -0,0 +1,24 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using System;
+using System.Collections.Generic;
+
+namespace AbpDesk.EntityFrameworkCore.Migrations
+{
+ public partial class Made_Permission_Entity_MultiTenant : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "TenantId",
+ table: "AbpPermissionGrants",
+ nullable: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "TenantId",
+ table: "AbpPermissionGrants");
+ }
+ }
+}
diff --git a/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/AbpDeskDbContextModelSnapshot.cs b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/AbpDeskDbContextModelSnapshot.cs
index c11ee7f323..26466a312d 100644
--- a/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/AbpDeskDbContextModelSnapshot.cs
+++ b/src/AbpDesk/AbpDesk.EntityFrameworkCore/Migrations/AbpDeskDbContextModelSnapshot.cs
@@ -90,6 +90,8 @@ namespace AbpDesk.EntityFrameworkCore.Migrations
.IsRequired()
.HasMaxLength(64);
+ b.Property("TenantId");
+
b.HasKey("Id");
b.HasIndex("Name", "ProviderName", "ProviderKey");
diff --git a/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/RolePermissionManagementProvider.cs b/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/RolePermissionManagementProvider.cs
index 5b50ee7c5a..aed01f7025 100644
--- a/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/RolePermissionManagementProvider.cs
+++ b/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/RolePermissionManagementProvider.cs
@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Guids;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Permissions;
namespace Volo.Abp.Identity
@@ -17,10 +18,12 @@ namespace Volo.Abp.Identity
public RolePermissionManagementProvider(
IPermissionGrantRepository permissionGrantRepository,
IGuidGenerator guidGenerator,
- IIdentityUserRepository identityUserRepository)
+ IIdentityUserRepository identityUserRepository,
+ ICurrentTenant currentTenant)
: base(
permissionGrantRepository,
- guidGenerator)
+ guidGenerator,
+ currentTenant)
{
_identityUserRepository = identityUserRepository;
}
diff --git a/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserPermissionManagementProvider.cs b/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserPermissionManagementProvider.cs
index b62602b838..8639140e3b 100644
--- a/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserPermissionManagementProvider.cs
+++ b/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserPermissionManagementProvider.cs
@@ -1,4 +1,5 @@
using Volo.Abp.Guids;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Permissions;
namespace Volo.Abp.Identity
@@ -11,10 +12,12 @@ namespace Volo.Abp.Identity
public UserPermissionManagementProvider(IPermissionGrantRepository
permissionGrantRepository,
- IGuidGenerator guidGenerator)
+ IGuidGenerator guidGenerator,
+ ICurrentTenant currentTenant)
: base(
permissionGrantRepository,
- guidGenerator)
+ guidGenerator,
+ currentTenant)
{
}
diff --git a/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionGrant.cs b/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionGrant.cs
index 38d0cc4c0a..8673bcd96c 100644
--- a/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionGrant.cs
+++ b/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionGrant.cs
@@ -1,11 +1,14 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Permissions
{
- public class PermissionGrant : Entity
+ public class PermissionGrant : Entity, IMultiTenant
{
+ public virtual Guid? TenantId { get; protected set; }
+
[NotNull]
public virtual string Name { get; protected set; }
@@ -24,7 +27,8 @@ namespace Volo.Abp.Permissions
Guid id,
[NotNull] string name,
[NotNull] string providerName ,
- [NotNull] string providerKey)
+ [NotNull] string providerKey,
+ Guid? tenantId = null)
{
Check.NotNull(name, nameof(name));
@@ -32,6 +36,7 @@ namespace Volo.Abp.Permissions
Name = name;
ProviderName = providerName;
ProviderKey = providerKey;
+ TenantId = tenantId;
}
}
}
diff --git a/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionManagementProvider.cs b/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionManagementProvider.cs
index 86a0a8a399..04d50f2a7d 100644
--- a/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionManagementProvider.cs
+++ b/src/Volo.Abp.Permissions.Domain/Volo/Abp/Permissions/PermissionManagementProvider.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Guids;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Permissions
{
@@ -12,12 +13,16 @@ namespace Volo.Abp.Permissions
protected IGuidGenerator GuidGenerator { get; }
+ protected ICurrentTenant CurrentTenant { get; }
+
protected PermissionManagementProvider(
IPermissionGrantRepository permissionGrantRepository,
- IGuidGenerator guidGenerator)
+ IGuidGenerator guidGenerator,
+ ICurrentTenant currentTenant)
{
PermissionGrantRepository = permissionGrantRepository;
GuidGenerator = guidGenerator;
+ CurrentTenant = currentTenant;
}
@@ -47,7 +52,8 @@ namespace Volo.Abp.Permissions
GuidGenerator.Create(),
name,
Name,
- providerKey
+ providerKey,
+ CurrentTenant.Id
)
);
}
diff --git a/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.Designer.cs b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.Designer.cs
new file mode 100644
index 0000000000..be6c942741
--- /dev/null
+++ b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.Designer.cs
@@ -0,0 +1,52 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.EntityFrameworkCore.Storage.Internal;
+using System;
+using Volo.Abp.Permissions.EntityFrameworkCore;
+
+namespace Volo.Abp.Permissions.EntityFrameworkCore.Migrations
+{
+ [DbContext(typeof(AbpPermissionsDbContext))]
+ [Migration("20180218143233_Made_Permission_Entity_MultiTenant")]
+ partial class Made_Permission_Entity_MultiTenant
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.0.1-rtm-125")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Volo.Abp.Permissions.PermissionGrant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128);
+
+ b.Property("ProviderKey")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("ProviderName")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("TenantId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name", "ProviderName", "ProviderKey");
+
+ b.ToTable("AbpPermissionGrants");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.cs b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.cs
new file mode 100644
index 0000000000..97e03b270b
--- /dev/null
+++ b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/20180218143233_Made_Permission_Entity_MultiTenant.cs
@@ -0,0 +1,38 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+using System;
+using System.Collections.Generic;
+
+namespace Volo.Abp.Permissions.EntityFrameworkCore.Migrations
+{
+ public partial class Made_Permission_Entity_MultiTenant : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "AbpPermissionGrants",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false),
+ Name = table.Column(maxLength: 128, nullable: false),
+ ProviderKey = table.Column(maxLength: 64, nullable: false),
+ ProviderName = table.Column(maxLength: 64, nullable: false),
+ TenantId = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey",
+ table: "AbpPermissionGrants",
+ columns: new[] { "Name", "ProviderName", "ProviderKey" });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "AbpPermissionGrants");
+ }
+ }
+}
diff --git a/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/AbpPermissionsDbContextModelSnapshot.cs b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/AbpPermissionsDbContextModelSnapshot.cs
new file mode 100644
index 0000000000..4e0f1c2397
--- /dev/null
+++ b/src/Volo.Abp.Permissions.EntityFrameworkCore/Migrations/AbpPermissionsDbContextModelSnapshot.cs
@@ -0,0 +1,51 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.EntityFrameworkCore.Storage.Internal;
+using System;
+using Volo.Abp.Permissions.EntityFrameworkCore;
+
+namespace Volo.Abp.Permissions.EntityFrameworkCore.Migrations
+{
+ [DbContext(typeof(AbpPermissionsDbContext))]
+ partial class AbpPermissionsDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.0.1-rtm-125")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Volo.Abp.Permissions.PermissionGrant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128);
+
+ b.Property("ProviderKey")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("ProviderName")
+ .IsRequired()
+ .HasMaxLength(64);
+
+ b.Property("TenantId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Name", "ProviderName", "ProviderKey");
+
+ b.ToTable("AbpPermissionGrants");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo.Abp.Permissions.EntityFrameworkCore.csproj b/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo.Abp.Permissions.EntityFrameworkCore.csproj
index f2fd254586..fdcd856367 100644
--- a/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo.Abp.Permissions.EntityFrameworkCore.csproj
+++ b/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo.Abp.Permissions.EntityFrameworkCore.csproj
@@ -18,4 +18,8 @@
+
+
+
+
diff --git a/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo/Abp/Permissions/EntityFrameworkCore/AbpPermissionsDbContextFactory.cs b/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo/Abp/Permissions/EntityFrameworkCore/AbpPermissionsDbContextFactory.cs
new file mode 100644
index 0000000000..a551cab544
--- /dev/null
+++ b/src/Volo.Abp.Permissions.EntityFrameworkCore/Volo/Abp/Permissions/EntityFrameworkCore/AbpPermissionsDbContextFactory.cs
@@ -0,0 +1,18 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Design;
+
+namespace Volo.Abp.Permissions.EntityFrameworkCore
+{
+ /* This class is needed for EF Core command line tooling */
+
+ public class AbpPermissionsDbContextFactory : IDesignTimeDbContextFactory
+ {
+ public AbpPermissionsDbContext CreateDbContext(string[] args)
+ {
+ //TODO: Remove all SqlServer references from EFCore packages and find a way of creating factory inside this.
+ var builder = new DbContextOptionsBuilder();
+ builder.UseSqlServer("Server=localhost;Database=AbpDesk;Trusted_Connection=True;");
+ return new AbpPermissionsDbContext(builder.Options);
+ }
+ }
+}