diff --git a/src/Example.Data/Example.Data.xproj b/src/Example.Data/Example.Data.xproj
new file mode 100644
index 0000000..8249411
--- /dev/null
+++ b/src/Example.Data/Example.Data.xproj
@@ -0,0 +1,20 @@
+
+
+
+ 14.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+
+ 2057c0d5-2da8-4327-bf8f-1a008783b38c
+ Example.Data
+ ..\..\artifacts\obj\$(MSBuildProjectName)
+ ..\..\artifacts\bin\$(MSBuildProjectName)\
+
+
+
+ 2.0
+
+
+
diff --git a/src/Example.Data/ExampleDbContext.cs b/src/Example.Data/ExampleDbContext.cs
new file mode 100644
index 0000000..c4f37c2
--- /dev/null
+++ b/src/Example.Data/ExampleDbContext.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
+using WaCore.Data;
+
+namespace Example.Data
+{
+ public class ExampleDbContext : WaCoreDbContext
+ {
+ public ExampleDbContext(DbContextOptions options) :
+ base(options)
+ { }
+ protected override void OnModelCreating(ModelBuilder builder)
+ {
+ base.OnModelCreating(builder);
+ // Customize the ASP.NET Identity model and override the defaults if needed.
+ // For example, you can rename the ASP.NET Identity table names and more.
+ // Add your customizations after calling base.OnModelCreating(builder);
+ }
+ }
+}
diff --git a/src/Example.Data/Migrations/20151225142128_Initial.Designer.cs b/src/Example.Data/Migrations/20151225142128_Initial.Designer.cs
new file mode 100644
index 0000000..159b498
--- /dev/null
+++ b/src/Example.Data/Migrations/20151225142128_Initial.Designer.cs
@@ -0,0 +1,242 @@
+using System;
+using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
+using Microsoft.Data.Entity.Metadata;
+using Microsoft.Data.Entity.Migrations;
+using Example.Data;
+
+namespace Example.Data.Migrations
+{
+ [DbContext(typeof(ExampleDbContext))]
+ [Migration("20151225142128_Initial")]
+ partial class Initial
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+ modelBuilder
+ .Annotation("ProductVersion", "7.0.0-beta8-15964")
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("RoleId");
+
+ b.HasKey("Id");
+
+ b.Annotation("Relational:TableName", "AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("UserId");
+
+ b.HasKey("Id");
+
+ b.Annotation("Relational:TableName", "AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider");
+
+ b.Property("ProviderKey");
+
+ b.Property("ProviderDisplayName");
+
+ b.Property("UserId");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.Annotation("Relational:TableName", "AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("RoleId");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.Annotation("Relational:TableName", "AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.Permission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Description");
+
+ b.Property("Name")
+ .Annotation("MaxLength", 256);
+
+ b.Property("NormalizedName")
+ .Annotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.Index("NormalizedName")
+ .Annotation("Relational:Name", "RoleNameIndex");
+
+ b.Annotation("Relational:TableName", "AspNetRoles");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.RolePermission", b =>
+ {
+ b.Property("PermissionId");
+
+ b.Property("RoleId");
+
+ b.HasKey("PermissionId", "RoleId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessFailedCount");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Email")
+ .Annotation("MaxLength", 256);
+
+ b.Property("EmailConfirmed");
+
+ b.Property("HashedPassword");
+
+ b.Property("LockoutEnabled");
+
+ b.Property("LockoutEnd");
+
+ b.Property("Name");
+
+ b.Property("NormalizedEmail")
+ .Annotation("MaxLength", 256);
+
+ b.Property("NormalizedUserName")
+ .Annotation("MaxLength", 256);
+
+ b.Property("PasswordHash");
+
+ b.Property("PhoneNumber");
+
+ b.Property("PhoneNumberConfirmed");
+
+ b.Property("PlainPassword");
+
+ b.Property("SecurityStamp");
+
+ b.Property("TwoFactorEnabled");
+
+ b.Property("UserName")
+ .Annotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.Index("NormalizedEmail")
+ .Annotation("Relational:Name", "EmailIndex");
+
+ b.Index("NormalizedUserName")
+ .Annotation("Relational:Name", "UserNameIndex");
+
+ b.Annotation("Relational:TableName", "AspNetUsers");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.UserPermission", b =>
+ {
+ b.Property("PermissionId");
+
+ b.Property("UserId");
+
+ b.HasKey("PermissionId", "UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.RolePermission", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Permission")
+ .WithMany()
+ .ForeignKey("PermissionId");
+
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.UserPermission", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Permission")
+ .WithMany()
+ .ForeignKey("PermissionId");
+
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+ }
+ }
+}
diff --git a/src/Example.Data/Migrations/20151225142128_Initial.cs b/src/Example.Data/Migrations/20151225142128_Initial.cs
new file mode 100644
index 0000000..414db37
--- /dev/null
+++ b/src/Example.Data/Migrations/20151225142128_Initial.cs
@@ -0,0 +1,211 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Data.Entity.Migrations;
+using Microsoft.Data.Entity.Metadata;
+
+namespace Example.Data.Migrations
+{
+ public partial class Initial : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Permission",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false),
+ Description = table.Column(nullable: true),
+ Name = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Permission", x => x.Id);
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetRoles",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false),
+ ConcurrencyStamp = table.Column(nullable: true),
+ Description = table.Column(nullable: true),
+ Name = table.Column(nullable: true),
+ NormalizedName = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Role", x => x.Id);
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetUsers",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false),
+ AccessFailedCount = table.Column(nullable: false),
+ ConcurrencyStamp = table.Column(nullable: true),
+ Email = table.Column(nullable: true),
+ EmailConfirmed = table.Column(nullable: false),
+ HashedPassword = table.Column(nullable: true),
+ LockoutEnabled = table.Column(nullable: false),
+ LockoutEnd = table.Column(nullable: true),
+ Name = table.Column(nullable: true),
+ NormalizedEmail = table.Column(nullable: true),
+ NormalizedUserName = table.Column(nullable: true),
+ PasswordHash = table.Column(nullable: true),
+ PhoneNumber = table.Column(nullable: true),
+ PhoneNumberConfirmed = table.Column(nullable: false),
+ PlainPassword = table.Column(nullable: true),
+ SecurityStamp = table.Column(nullable: true),
+ TwoFactorEnabled = table.Column(nullable: false),
+ UserName = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_User", x => x.Id);
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetRoleClaims",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ ClaimType = table.Column(nullable: true),
+ ClaimValue = table.Column(nullable: true),
+ RoleId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_IdentityRoleClaim", x => x.Id);
+ table.ForeignKey(
+ name: "FK_IdentityRoleClaim_Role_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateTable(
+ name: "RolePermission",
+ columns: table => new
+ {
+ PermissionId = table.Column(nullable: false),
+ RoleId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RolePermission", x => new { x.PermissionId, x.RoleId });
+ table.ForeignKey(
+ name: "FK_RolePermission_Permission_PermissionId",
+ column: x => x.PermissionId,
+ principalTable: "Permission",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_RolePermission_Role_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetUserClaims",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
+ ClaimType = table.Column(nullable: true),
+ ClaimValue = table.Column(nullable: true),
+ UserId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_IdentityUserClaim", x => x.Id);
+ table.ForeignKey(
+ name: "FK_IdentityUserClaim_User_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetUserLogins",
+ columns: table => new
+ {
+ LoginProvider = table.Column(nullable: false),
+ ProviderKey = table.Column(nullable: false),
+ ProviderDisplayName = table.Column(nullable: true),
+ UserId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_IdentityUserLogin", x => new { x.LoginProvider, x.ProviderKey });
+ table.ForeignKey(
+ name: "FK_IdentityUserLogin_User_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateTable(
+ name: "AspNetUserRoles",
+ columns: table => new
+ {
+ UserId = table.Column(nullable: false),
+ RoleId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_IdentityUserRole", x => new { x.UserId, x.RoleId });
+ table.ForeignKey(
+ name: "FK_IdentityUserRole_Role_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_IdentityUserRole_User_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateTable(
+ name: "UserPermission",
+ columns: table => new
+ {
+ PermissionId = table.Column(nullable: false),
+ UserId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_UserPermission", x => new { x.PermissionId, x.UserId });
+ table.ForeignKey(
+ name: "FK_UserPermission_Permission_PermissionId",
+ column: x => x.PermissionId,
+ principalTable: "Permission",
+ principalColumn: "Id");
+ table.ForeignKey(
+ name: "FK_UserPermission_User_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id");
+ });
+ migrationBuilder.CreateIndex(
+ name: "RoleNameIndex",
+ table: "AspNetRoles",
+ column: "NormalizedName");
+ migrationBuilder.CreateIndex(
+ name: "EmailIndex",
+ table: "AspNetUsers",
+ column: "NormalizedEmail");
+ migrationBuilder.CreateIndex(
+ name: "UserNameIndex",
+ table: "AspNetUsers",
+ column: "NormalizedUserName");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable("AspNetRoleClaims");
+ migrationBuilder.DropTable("AspNetUserClaims");
+ migrationBuilder.DropTable("AspNetUserLogins");
+ migrationBuilder.DropTable("AspNetUserRoles");
+ migrationBuilder.DropTable("RolePermission");
+ migrationBuilder.DropTable("UserPermission");
+ migrationBuilder.DropTable("AspNetRoles");
+ migrationBuilder.DropTable("Permission");
+ migrationBuilder.DropTable("AspNetUsers");
+ }
+ }
+}
diff --git a/src/Example.Data/Migrations/ExampleDbContextModelSnapshot.cs b/src/Example.Data/Migrations/ExampleDbContextModelSnapshot.cs
new file mode 100644
index 0000000..20c0356
--- /dev/null
+++ b/src/Example.Data/Migrations/ExampleDbContextModelSnapshot.cs
@@ -0,0 +1,241 @@
+using System;
+using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
+using Microsoft.Data.Entity.Metadata;
+using Microsoft.Data.Entity.Migrations;
+using Example.Data;
+
+namespace Example.Data.Migrations
+{
+ [DbContext(typeof(ExampleDbContext))]
+ partial class ExampleDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+ modelBuilder
+ .Annotation("ProductVersion", "7.0.0-beta8-15964")
+ .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("RoleId");
+
+ b.HasKey("Id");
+
+ b.Annotation("Relational:TableName", "AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("UserId");
+
+ b.HasKey("Id");
+
+ b.Annotation("Relational:TableName", "AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider");
+
+ b.Property("ProviderKey");
+
+ b.Property("ProviderDisplayName");
+
+ b.Property("UserId");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.Annotation("Relational:TableName", "AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("RoleId");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.Annotation("Relational:TableName", "AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.Permission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Description");
+
+ b.Property("Name")
+ .Annotation("MaxLength", 256);
+
+ b.Property("NormalizedName")
+ .Annotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.Index("NormalizedName")
+ .Annotation("Relational:Name", "RoleNameIndex");
+
+ b.Annotation("Relational:TableName", "AspNetRoles");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.RolePermission", b =>
+ {
+ b.Property("PermissionId");
+
+ b.Property("RoleId");
+
+ b.HasKey("PermissionId", "RoleId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessFailedCount");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Email")
+ .Annotation("MaxLength", 256);
+
+ b.Property("EmailConfirmed");
+
+ b.Property("HashedPassword");
+
+ b.Property("LockoutEnabled");
+
+ b.Property("LockoutEnd");
+
+ b.Property("Name");
+
+ b.Property("NormalizedEmail")
+ .Annotation("MaxLength", 256);
+
+ b.Property("NormalizedUserName")
+ .Annotation("MaxLength", 256);
+
+ b.Property("PasswordHash");
+
+ b.Property("PhoneNumber");
+
+ b.Property("PhoneNumberConfirmed");
+
+ b.Property("PlainPassword");
+
+ b.Property("SecurityStamp");
+
+ b.Property("TwoFactorEnabled");
+
+ b.Property("UserName")
+ .Annotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.Index("NormalizedEmail")
+ .Annotation("Relational:Name", "EmailIndex");
+
+ b.Index("NormalizedUserName")
+ .Annotation("Relational:Name", "UserNameIndex");
+
+ b.Annotation("Relational:TableName", "AspNetUsers");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.UserPermission", b =>
+ {
+ b.Property("PermissionId");
+
+ b.Property("UserId");
+
+ b.HasKey("PermissionId", "UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.RolePermission", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Permission")
+ .WithMany()
+ .ForeignKey("PermissionId");
+
+ b.HasOne("WaCore.Entities.Core.Role")
+ .WithMany()
+ .ForeignKey("RoleId");
+ });
+
+ modelBuilder.Entity("WaCore.Entities.Core.UserPermission", b =>
+ {
+ b.HasOne("WaCore.Entities.Core.Permission")
+ .WithMany()
+ .ForeignKey("PermissionId");
+
+ b.HasOne("WaCore.Entities.Core.User")
+ .WithMany()
+ .ForeignKey("UserId");
+ });
+ }
+ }
+}
diff --git a/src/Example.Data/Properties/AssemblyInfo.cs b/src/Example.Data/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3e07a68
--- /dev/null
+++ b/src/Example.Data/Properties/AssemblyInfo.cs
@@ -0,0 +1,23 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Example.Data")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Example.Data")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2057c0d5-2da8-4327-bf8f-1a008783b38c")]
diff --git a/src/Example.Data/Startup.cs b/src/Example.Data/Startup.cs
new file mode 100644
index 0000000..d1c1ef5
--- /dev/null
+++ b/src/Example.Data/Startup.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Builder;
+using Microsoft.AspNet.Hosting;
+using Microsoft.Framework.Configuration;
+using Microsoft.Framework.DependencyInjection;
+using WaCore.Entities.Core;
+using Microsoft.Data.Entity;
+using Microsoft.Dnx.Runtime;
+
+namespace Example.Data
+{
+ public class Startup
+ {
+ public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
+ {
+ // Setup configuration sources.
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(appEnv.ApplicationBasePath)
+ .AddJsonFile("appsettings.json")
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
+
+
+ if (env.IsEnvironment("Development"))
+ {
+ // This reads the configuration keys from the secret store.
+ // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
+ //builder.AddUserSecrets();
+ }
+
+
+ // most common use of environment variables would be in azure hosting
+ // since it is added last anything in env vars would trump the same setting in previous config sources
+ // so no risk of messing up settings if deploying a new version to azure
+ builder.AddEnvironmentVariables();
+ Configuration = builder.Build();
+ }
+
+ public IConfigurationRoot Configuration { get; set; }
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ // Add Entity Framework services to the services container.
+ services.AddEntityFramework()
+ .AddSqlServer()
+ .AddDbContext(options =>
+ options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
+
+ services.AddIdentity()
+ .AddEntityFrameworkStores()
+ .AddDefaultTokenProviders();
+ }
+
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ {
+ }
+ }
+}
diff --git a/src/Example.Data/appsettings.json b/src/Example.Data/appsettings.json
new file mode 100644
index 0000000..12b9d49
--- /dev/null
+++ b/src/Example.Data/appsettings.json
@@ -0,0 +1,7 @@
+{
+ "Data": {
+ "DefaultConnection": {
+ "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=WaCoreExample;Trusted_Connection=True;"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Example.Data/project.json b/src/Example.Data/project.json
new file mode 100644
index 0000000..a35ea91
--- /dev/null
+++ b/src/Example.Data/project.json
@@ -0,0 +1,30 @@
+{
+ "version": "1.0.0-*",
+ "description": "Example.Data Class Library",
+ "authors": [ "h.bodner" ],
+ "tags": [ "" ],
+ "projectUrl": "",
+ "licenseUrl": "",
+
+ "frameworks": {
+ "dnx451": { },
+ "dnxcore50": {
+ "dependencies": {
+ "Microsoft.CSharp": "4.0.1-beta-23409",
+ "System.Collections": "4.0.11-beta-23409",
+ "System.Linq": "4.0.1-beta-23409",
+ "System.Runtime": "4.0.21-beta-23409",
+ "System.Threading": "4.0.11-beta-23409"
+ }
+ }
+ },
+ "dependencies": {
+ "EntityFramework.Commands": "7.0.0-beta8",
+ "EntityFramework.SqlServer": "7.0.0-beta8",
+ "WaCore.Data": "1.0.0-*",
+ "WaCore.Contracts": "1.0.0-*"
+ },
+ "commands": {
+ "ef": "EntityFramework.Commands"
+ },
+}
diff --git a/src/Example.Web/Startup.cs b/src/Example.Web/Startup.cs
index c3a08de..a4911dc 100644
--- a/src/Example.Web/Startup.cs
+++ b/src/Example.Web/Startup.cs
@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Example.Data;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
@@ -48,14 +50,13 @@ public void ConfigureServices(IServiceCollection services)
// Add Entity Framework services to the services container.
services.AddEntityFramework()
.AddSqlServer()
- .AddDbContext(options =>
+ .AddDbContext(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
-
services.ConfigureWaCore(Configuration);
services.AddIdentity()
- .AddEntityFrameworkStores()
+ .AddEntityFrameworkStores()
.AddDefaultTokenProviders();
}
diff --git a/src/Example.Web/project.json b/src/Example.Web/project.json
index 9b798fa..f1bba6c 100644
--- a/src/Example.Web/project.json
+++ b/src/Example.Web/project.json
@@ -14,7 +14,8 @@
"WaCore.Web": "1.0.0-*",
"WaCore.Entities": "1.0.0-*",
"WaCore.Bl": "1.0.0-*",
- "WaCore.Data": "1.0.0-*"
+ "WaCore.Data": "1.0.0-*",
+ "Example.Data": "1.0.0-*"
},
"commands": {
diff --git a/src/WaCore.Data/WaCoreDbContext.cs b/src/WaCore.Data/WaCoreDbContext.cs
index 61d31cd..2f0aab4 100644
--- a/src/WaCore.Data/WaCoreDbContext.cs
+++ b/src/WaCore.Data/WaCoreDbContext.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
using WaCore.Contracts.Entities.Core;
using WaCore.Entities.Core;
@@ -11,12 +12,21 @@ namespace WaCore.Data
{
public class WaCoreDbContext : IdentityDbContext
{
+ public WaCoreDbContext(DbContextOptions options) : base(options)
+ {
+ }
+
+ public DbSet Permissions { get; set; }
+
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
+
+ builder.Entity().HasKey(x => new {x.PermissionId, x.UserId});
+ builder.Entity().HasKey(x => new { x.PermissionId, x.RoleId });
}
}
}
diff --git a/src/WaCore.Data/project.json b/src/WaCore.Data/project.json
index bae5f28..fb5f6de 100644
--- a/src/WaCore.Data/project.json
+++ b/src/WaCore.Data/project.json
@@ -21,6 +21,6 @@
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"WaCore.Contracts": "1.0.0-*",
- "WaCore.Entities": "1.0.0-*"
+ "WaCore.Entities": "1.0.0-*"
}
}
diff --git a/src/WaCore.Entities/Core/Permission.cs b/src/WaCore.Entities/Core/Permission.cs
index 879e85c..dab73f3 100644
--- a/src/WaCore.Entities/Core/Permission.cs
+++ b/src/WaCore.Entities/Core/Permission.cs
@@ -7,10 +7,20 @@ namespace WaCore.Entities.Core
{
public class Permission
{
+ public Permission()
+ {
+ UserPermissions = new HashSet();
+ RolePermissions = new HashSet();
+ }
+
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
+
+ public virtual ICollection UserPermissions { get; set; }
+
+ public virtual ICollection RolePermissions { get; set; }
}
}
diff --git a/src/WaCore.Entities/Core/Role.cs b/src/WaCore.Entities/Core/Role.cs
index 47cb405..72fb33d 100644
--- a/src/WaCore.Entities/Core/Role.cs
+++ b/src/WaCore.Entities/Core/Role.cs
@@ -9,8 +9,12 @@ namespace WaCore.Entities.Core
{
public class Role : IdentityRole
{
+ public Role()
+ {
+ RolePermissions = new HashSet();
+ }
public string Description { get; set; }
- public virtual ICollection Permissions { get; set; }
+ public virtual ICollection RolePermissions { get; set; }
}
}
diff --git a/src/WaCore.Entities/Core/RolePermission.cs b/src/WaCore.Entities/Core/RolePermission.cs
new file mode 100644
index 0000000..3c5deb0
--- /dev/null
+++ b/src/WaCore.Entities/Core/RolePermission.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace WaCore.Entities.Core
+{
+ public class RolePermission
+ {
+ public Guid RoleId { get; set; }
+ public Role Role { get; set; }
+
+ public Guid PermissionId { get; set; }
+ public Permission Permission { get; set; }
+ }
+}
diff --git a/src/WaCore.Entities/Core/User.cs b/src/WaCore.Entities/Core/User.cs
index aac99be..ea93d7c 100644
--- a/src/WaCore.Entities/Core/User.cs
+++ b/src/WaCore.Entities/Core/User.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Microsoft.AspNet.Identity.EntityFramework;
using WaCore.Contracts.Entities.Core;
@@ -6,8 +7,15 @@ namespace WaCore.Entities.Core
{
public class User : IdentityUser, IUser
{
+ public User()
+ {
+ UserPermissions = new HashSet();
+ }
+
public string PlainPassword { get; set; }
public string HashedPassword { get; set; }
public string Name { get; set; }
+
+ public virtual ICollection UserPermissions { get; set; }
}
}
diff --git a/src/WaCore.Entities/Core/UserPermission.cs b/src/WaCore.Entities/Core/UserPermission.cs
new file mode 100644
index 0000000..147beae
--- /dev/null
+++ b/src/WaCore.Entities/Core/UserPermission.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace WaCore.Entities.Core
+{
+ public class UserPermission
+ {
+ public Guid UserId { get; set; }
+ public User User { get; set; }
+
+ public Guid PermissionId { get; set; }
+ public Permission Permission { get; set; }
+ }
+}
diff --git a/webapp-core.sln b/webapp-core.sln
index c2f011f..cf3d4a3 100644
--- a/webapp-core.sln
+++ b/webapp-core.sln
@@ -25,6 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Example", "Example", "{DD16
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Example.Web", "src\Example.Web\Example.Web.xproj", "{F3821ADD-E25F-42F3-BD78-FBBA722416D9}"
EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Example.Data", "src\Example.Data\Example.Data.xproj", "{2057C0D5-2DA8-4327-BF8F-1A008783B38C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -63,6 +65,10 @@ Global
{F3821ADD-E25F-42F3-BD78-FBBA722416D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3821ADD-E25F-42F3-BD78-FBBA722416D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3821ADD-E25F-42F3-BD78-FBBA722416D9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2057C0D5-2DA8-4327-BF8F-1A008783B38C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2057C0D5-2DA8-4327-BF8F-1A008783B38C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2057C0D5-2DA8-4327-BF8F-1A008783B38C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2057C0D5-2DA8-4327-BF8F-1A008783B38C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -71,5 +77,6 @@ Global
{3EF2DD50-A645-45BD-9E11-B1EB321AC18B} = {F9D275A9-E78F-4C80-8241-8809DCB075CF}
{6FBD59CF-6465-4C3E-BDB8-BBA1CA87DFF5} = {E874E752-FCCF-40B5-B99C-1E7DC3F31AFE}
{F3821ADD-E25F-42F3-BD78-FBBA722416D9} = {DD16C4F1-9516-4270-A6E4-26C3C13DD39E}
+ {2057C0D5-2DA8-4327-BF8F-1A008783B38C} = {DD16C4F1-9516-4270-A6E4-26C3C13DD39E}
EndGlobalSection
EndGlobal