├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── Settings.StyleCop ├── XperiAndri.AspNet.Identity.sln ├── docs ├── Database-First.md └── img │ ├── Add T4 Template.png │ ├── Create project.png │ ├── Mark entities.png │ └── Mark keys.png ├── examples └── XperiAndri.AspNet.Identity.DbFirst │ ├── Properties │ └── AssemblyInfo.cs │ ├── Security │ └── ApplicationOAuthProvider.cs │ ├── Startup.cs │ ├── Web.config │ ├── XperiAndri.AspNet.Identity.DbFirst.csproj │ ├── app.js │ ├── index.html │ └── packages.config ├── src ├── Templates12 │ ├── XperiAndri.AspNet.Identity.DatabaseTemplate │ │ ├── Asp.NetIdentity.vstemplate │ │ ├── MyTemplate.vstemplate │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Publish Profiles │ │ │ └── Local.publish.xml │ │ ├── TemplateIcon.ico │ │ ├── XperiAndri.AspNet.Identity.DatabaseTemplate.csproj │ │ └── XperiAndri.AspNetIdentity.Database.sqlproj │ ├── XperiAndri.AspNet.Identity.EFDesignerExtension – копія │ │ ├── Constants.cs │ │ ├── IdentityEntityProperties.cs │ │ ├── IdentityEntityPropertiesFactory.cs │ │ ├── IdentityEntityPropertyEditor.cs │ │ ├── ModelGenerationExtension.cs │ │ ├── ModelTransformExtension.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── PropertyManager.cs │ │ └── XperiAndri.AspNet.Identity.EFDesignerExtension.csproj │ ├── XperiAndri.AspNet.Identity.EFDesignerExtension │ │ ├── Constants.cs │ │ ├── IdentityEntityProperties.cs │ │ ├── IdentityEntityPropertiesFactory.cs │ │ ├── IdentityEntityPropertyEditor.cs │ │ ├── ModelGenerationExtension.cs │ │ ├── ModelTransformExtension.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── PropertyManager.cs │ │ └── XperiAndri.AspNet.Identity.EFDesignerExtension.csproj │ ├── XperiAndri.AspNet.Identity.EntitiesTemplate │ │ ├── ADONETArtifactGenerator_AspNetIdentityClasses.vstemplate │ │ ├── AspNetIdentity.tt │ │ ├── Identity │ │ │ └── UserStore.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Resources.resx │ │ ├── TemplateIcon.ico │ │ └── XperiAndri.AspNet.Identity.EntitiesTemplate.csproj │ ├── XperiAndri.AspNet.Identity.Package │ │ ├── LICENSE.txt │ │ ├── PackageIcon.ico │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Source.extension.vsixmanifest │ │ └── XperiAndri.AspNet.Identity.Package.csproj │ └── XperiAndri.AspNet.Identity.Vsix.sln ├── Templates14 │ ├── XperiAndri.AspNet.Identity.DatabaseTemplate │ │ ├── Asp.NetIdentity.vstemplate │ │ ├── MyTemplate.vstemplate │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Publish Profiles │ │ │ └── Local.publish.xml │ │ ├── TemplateIcon.ico │ │ ├── XperiAndri.AspNet.Identity.DatabaseTemplate.csproj │ │ └── XperiAndri.AspNetIdentity.Database.sqlproj │ ├── XperiAndri.AspNet.Identity.EFDesignerExtension – копія │ │ ├── Constants.cs │ │ ├── IdentityEntityProperties.cs │ │ ├── IdentityEntityPropertiesFactory.cs │ │ ├── IdentityEntityPropertyEditor.cs │ │ ├── ModelGenerationExtension.cs │ │ ├── ModelTransformExtension.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── PropertyManager.cs │ │ └── XperiAndri.AspNet.Identity.EFDesignerExtension.csproj │ ├── XperiAndri.AspNet.Identity.EFDesignerExtension │ │ ├── Constants.cs │ │ ├── IdentityEntityProperties.cs │ │ ├── IdentityEntityPropertiesFactory.cs │ │ ├── IdentityEntityPropertyEditor.cs │ │ ├── ModelGenerationExtension.cs │ │ ├── ModelTransformExtension.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── PropertyManager.cs │ │ └── XperiAndri.AspNet.Identity.EFDesignerExtension.csproj │ ├── XperiAndri.AspNet.Identity.EntitiesTemplate │ │ ├── ADONETArtifactGenerator_AspNetIdentityClasses.vstemplate │ │ ├── AspNetIdentity.tt │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Resources.resx │ │ ├── TemplateIcon.ico │ │ └── XperiAndri.AspNet.Identity.EntitiesTemplate.csproj │ ├── XperiAndri.AspNet.Identity.Package │ │ ├── LICENSE.txt │ │ ├── PackageIcon.ico │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Source.extension.vsixmanifest │ │ └── XperiAndri.AspNet.Identity.Package.csproj │ └── XperiAndri.AspNet.Identity.Vsix.sln ├── XperiAndri.AspNet.Identity.Database │ ├── Publish Profiles │ │ └── Local.publish.xml │ ├── Reference Data │ │ ├── RolesOfUsers.sql │ │ ├── UserRoles.sql │ │ └── Users.sql │ ├── Scripts │ │ └── PostDeployment.sql │ ├── Tables │ │ ├── RolesOfUsers.sql │ │ ├── UserClaims.sql │ │ ├── UserLogins.sql │ │ ├── UserRoles.sql │ │ └── Users.sql │ ├── User Defined Types │ │ ├── Email.sql │ │ ├── Flag.sql │ │ ├── Name.sql │ │ └── Phone.sql │ └── XperiAndri.AspNet.Identity.Database.sqlproj └── XperiAndri.AspNet.Identity.EntityFramework │ ├── App.config │ ├── Identity │ ├── IdentityExtensions.cs │ ├── RoleStore.cs │ └── UserStore.cs │ ├── Models │ ├── IdentityModels.cs │ ├── Model.Context.cs │ ├── Model.Context.tt │ ├── Model.Designer.cs │ ├── Model.Impl.cs │ ├── Model.cs │ ├── Model.edmx │ ├── Model.edmx.diagram │ ├── Model.tt │ ├── User.cs │ ├── UserClaim.cs │ ├── UserLogin.cs │ └── UserRole.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── XperiAndri.AspNet.Identity.EntityFramework.csproj │ └── packages.config └── test └── XperiAndri.AspNet.Identity.EntityFramework.Tests ├── Properties └── AssemblyInfo.cs ├── XperiAndri.AspNet.Identity.EntityFramework.Tests.csproj └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.sqlproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | #*.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/ 133 | 134 | # Windows Azure Build Output 135 | csx 136 | *.build.csdef 137 | 138 | # Windows Store app package directory 139 | AppPackages/ 140 | 141 | # Others 142 | sql/ 143 | *.Cache 144 | ClientBin/ 145 | [Ss]tyle[Cc]op.* 146 | ~$* 147 | *~ 148 | *.dbmdl 149 | #*.[Pp]ublish.xml 150 | *.pfx 151 | *.publishsettings 152 | 153 | # RIA/Silverlight projects 154 | Generated_Code/ 155 | 156 | # Backup & report files from converting an old project file to a newer 157 | # Visual Studio version. Backup files are not needed, because we have git ;-) 158 | _UpgradeReport_Files/ 159 | Backup*/ 160 | UpgradeLog*.XML 161 | UpgradeLog*.htm 162 | 163 | # SQL Server files 164 | App_Data/*.mdf 165 | App_Data/*.ldf 166 | 167 | ############# 168 | ## Windows detritus 169 | ############# 170 | 171 | # Windows image file caches 172 | Thumbs.db 173 | ehthumbs.db 174 | 175 | # Folder config file 176 | Desktop.ini 177 | 178 | # Recycle Bin used on file shares 179 | $RECYCLE.BIN/ 180 | 181 | # Mac crap 182 | .DS_Store 183 | 184 | 185 | ############# 186 | ## Python 187 | ############# 188 | 189 | *.py[co] 190 | 191 | # Packages 192 | *.egg 193 | *.egg-info 194 | dist/ 195 | build/ 196 | eggs/ 197 | parts/ 198 | var/ 199 | sdist/ 200 | develop-eggs/ 201 | .installed.cfg 202 | 203 | # Installer logs 204 | pip-log.txt 205 | 206 | # Unit test / coverage reports 207 | .coverage 208 | .tox 209 | 210 | #Translations 211 | *.mo 212 | 213 | #Mr Developer 214 | .mr.developer.cfg 215 | 216 | 217 | README.html 218 | README.min.html 219 | docs/*.html 220 | src/Templates -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Andrii Chebukin, XperiAndri LLC. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ASP.NET Identity tools for Entity Framework model 2 | ================================ 3 | 4 | > This projects demonstrates how to use [ASP.NET Identity](http://asp.net/identity) with 5 | > Entity Framework data model. 6 | 7 | [Getting Started with ASP.NET Identity tools for Entity Framework model](./docs/Entity-Data-Model.md) 8 | 9 | ![ASP.NET Identity Model](http://i.imgur.com/KHDqq3B.png) 10 | 11 | ### Download 12 | 13 | [Visual Studio 2013](https://visualstudiogallery.msdn.microsoft.com/cd93cdd1-97ed-4a57-8aea-5c07c71a294c) 14 | 15 | [Visual Studio 2015](https://visualstudiogallery.msdn.microsoft.com/e48464e9-5f10-442a-a6a3-a30117dd5209) 16 | 17 | ![ASP.NET Identity Database Project Template](./docs/img/Create project.png) 18 | 19 | ![ASP.NET Identity Database](http://i.imgur.com/9jV1deH.png) 20 | 21 | ### Authors 22 | 23 | * [Andrii Chebukin](http://www.fb.com/xperiandri) ([xperiandri@outlook.com](mailto:hello@tarkuks.me?subject=ASP.NET+Identity+tools+for+Entity+Framework+model)) - author of improved version 24 | * [Konstantin Tarkus](https://angel.co/koistya) ([hello@tarkus.me](mailto:hello@tarkuks.me?subject=ASP.NET+Identity+Providers)) - original author 25 | 26 | ### License 27 | 28 | * **Source code**: the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) (see [LICENSE.txt](./LICENSE.txt)) 29 | * **Documentation**: the [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/) 30 | -------------------------------------------------------------------------------- /Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | False 8 | 9 | 10 | 11 | 12 | False 13 | 14 | 15 | 16 | 17 | False 18 | 19 | 20 | 21 | 22 | False 23 | 24 | 25 | 26 | 27 | False 28 | 29 | 30 | 31 | 32 | False 33 | 34 | 35 | 36 | 37 | False 38 | 39 | 40 | 41 | 42 | False 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | False 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /XperiAndri.AspNet.Identity.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".settings", ".settings", "{37F10E31-9EC4-4119-8DB5-03C780D049F6}" 7 | ProjectSection(SolutionItems) = preProject 8 | .gitattributes = .gitattributes 9 | .gitignore = .gitignore 10 | LICENSE.txt = LICENSE.txt 11 | README.md = README.md 12 | Settings.StyleCop = Settings.StyleCop 13 | EndProjectSection 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{BC75208A-D1F8-45F5-9109-A07252BAE377}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.DbFirst", "examples\XperiAndri.AspNet.Identity.DbFirst\XperiAndri.AspNet.Identity.DbFirst.csproj", "{6F013146-8A52-4B79-9B87-762647CD8600}" 18 | EndProject 19 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D306510E-56AA-46E9-A882-0B65386D51EE}" 20 | EndProject 21 | Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "XperiAndri.AspNet.Identity.Database", "src\XperiAndri.AspNet.Identity.Database\XperiAndri.AspNet.Identity.Database.sqlproj", "{C77AFCBD-25B7-4500-92DC-1248EDD6A89E}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EntityFramework", "src\XperiAndri.AspNet.Identity.EntityFramework\XperiAndri.AspNet.Identity.EntityFramework.csproj", "{311FECA9-F3CE-49A7-B085-B9DAFA25CA0A}" 24 | EndProject 25 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{51153F63-66A3-4DC4-A7DA-1AA66F966D91}" 26 | EndProject 27 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EntityFramework.Tests", "test\XperiAndri.AspNet.Identity.EntityFramework.Tests\XperiAndri.AspNet.Identity.EntityFramework.Tests.csproj", "{EDB5DE31-B19F-4105-8150-093CADEEB206}" 28 | EndProject 29 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C82E2BD5-3C58-4AF1-8596-613F67CA0090}" 30 | ProjectSection(SolutionItems) = preProject 31 | docs\Database-First.md = docs\Database-First.md 32 | EndProjectSection 33 | EndProject 34 | Global 35 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 36 | Debug|Any CPU = Debug|Any CPU 37 | Release|Any CPU = Release|Any CPU 38 | EndGlobalSection 39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 40 | {6F013146-8A52-4B79-9B87-762647CD8600}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {6F013146-8A52-4B79-9B87-762647CD8600}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {6F013146-8A52-4B79-9B87-762647CD8600}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {6F013146-8A52-4B79-9B87-762647CD8600}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 47 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E}.Release|Any CPU.Deploy.0 = Release|Any CPU 50 | {311FECA9-F3CE-49A7-B085-B9DAFA25CA0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {311FECA9-F3CE-49A7-B085-B9DAFA25CA0A}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {311FECA9-F3CE-49A7-B085-B9DAFA25CA0A}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {311FECA9-F3CE-49A7-B085-B9DAFA25CA0A}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {EDB5DE31-B19F-4105-8150-093CADEEB206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {EDB5DE31-B19F-4105-8150-093CADEEB206}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {EDB5DE31-B19F-4105-8150-093CADEEB206}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {EDB5DE31-B19F-4105-8150-093CADEEB206}.Release|Any CPU.Build.0 = Release|Any CPU 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | GlobalSection(NestedProjects) = preSolution 63 | {6F013146-8A52-4B79-9B87-762647CD8600} = {BC75208A-D1F8-45F5-9109-A07252BAE377} 64 | {C77AFCBD-25B7-4500-92DC-1248EDD6A89E} = {D306510E-56AA-46E9-A882-0B65386D51EE} 65 | {311FECA9-F3CE-49A7-B085-B9DAFA25CA0A} = {D306510E-56AA-46E9-A882-0B65386D51EE} 66 | {EDB5DE31-B19F-4105-8150-093CADEEB206} = {51153F63-66A3-4DC4-A7DA-1AA66F966D91} 67 | EndGlobalSection 68 | GlobalSection(CodealikeProperties) = postSolution 69 | SolutionGuid = 2e9aa1bb-4290-452c-8da4-ed003f142fe2 70 | EndGlobalSection 71 | EndGlobal 72 | -------------------------------------------------------------------------------- /docs/Database-First.md: -------------------------------------------------------------------------------- 1 | Getting Started with ASP.NET Identity and EF DbFirst 2 | ---------------------------------------------------- 3 | 4 | ### 1. Publish ASP.NET Identity Database Project 5 | 6 | SQL Database Project (SSDT): 7 | 8 | > `./src/KriaSoft.AspNet.Identity.Database` 9 | 10 | You can publish it by double-clicking on the `./Publish Profiles/Local.publish.xml` file in the Solution Explorer. 11 | 12 | ### 2. Generate Entity Framework model using EF Designer 13 | 14 | See ASP.NET Identity Database-First model example: 15 | 16 | > `./src/KriaSoft.AspNet.Identity.EntityFramework/Model.edmx` 17 | 18 | ### 3. Copy UserEntity.cs, UserRoleEntity.cs, RoleStore.cs, UserStore.cs and Resources into your project 19 | 20 | > See: `./src/KriaSoft.AspNet.Identity.EntityFramework/` 21 | 22 | And make sure property names in User, UserLogin, UserRole and UserClaim entities match the ones used in RoleStore and UserStore providers. 23 | 24 | ![ASP.NET Identity Model](http://i.imgur.com/KHDqq3B.png) 25 | 26 | ### 4. Done! You can use it like this: 27 | 28 | ```csharp 29 | var db = new ApplicationDbContext(); // your custom EF model 30 | var userManager = new UserManager(new UserStore(db)); 31 | 32 | userManager.CreateUserAsync(new User { UserName = "demouser" }); 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/img/Add T4 Template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/docs/img/Add T4 Template.png -------------------------------------------------------------------------------- /docs/img/Create project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/docs/img/Create project.png -------------------------------------------------------------------------------- /docs/img/Mark entities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/docs/img/Mark entities.png -------------------------------------------------------------------------------- /docs/img/Mark keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/docs/img/Mark keys.png -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.DbFirst")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("XperiAndri")] 11 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.DbFirst")] 12 | [assembly: AssemblyCopyright("Copyright © 2014 XperiAndri")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("041141b3-d83e-474a-83b8-d14a88e772af")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/Security/ApplicationOAuthProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.AspNet.Identity; 6 | using Microsoft.Owin.Security; 7 | using Microsoft.Owin.Security.Cookies; 8 | using Microsoft.Owin.Security.OAuth; 9 | using XperiAndri.AspNet.Identity.EntityFramework; 10 | using XperiAndri.AspNet.Identity.EntityFramework.Models; 11 | 12 | namespace XperiAndri.AspNet.Identity.DbFirst.Security 13 | { 14 | public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider 15 | { 16 | private readonly string publicClientId; 17 | private readonly Func> userManagerFactory; 18 | 19 | public ApplicationOAuthProvider(string publicClientId, Func> userManagerFactory) 20 | { 21 | if (publicClientId == null) 22 | { 23 | throw new ArgumentNullException("publicClientId"); 24 | } 25 | 26 | if (userManagerFactory == null) 27 | { 28 | throw new ArgumentNullException("userManagerFactory"); 29 | } 30 | 31 | this.publicClientId = publicClientId; 32 | this.userManagerFactory = userManagerFactory; 33 | } 34 | 35 | public static AuthenticationProperties CreateProperties(User user) 36 | { 37 | return new AuthenticationProperties(new Dictionary 38 | { 39 | { "userName", user.UserName }, 40 | { "email", user.Email }, 41 | { "emailConfirmed", user.EmailConfirmed.ToString() } 42 | }); 43 | } 44 | 45 | public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) 46 | { 47 | using (var userManager = this.userManagerFactory()) 48 | { 49 | var user = await userManager.FindAsync(context.UserName, context.Password); 50 | 51 | if (user == null) 52 | { 53 | context.SetError("invalid_grant", "The user name or password is incorrect."); 54 | return; 55 | } 56 | 57 | var oauthIdentity = await userManager.CreateIdentityAsync( 58 | user, context.Options.AuthenticationType); 59 | var cookiesIdentity = await userManager.CreateIdentityAsync( 60 | user, CookieAuthenticationDefaults.AuthenticationType); 61 | var properties = CreateProperties(user); 62 | var ticket = new AuthenticationTicket(oauthIdentity, properties); 63 | context.Validated(ticket); 64 | context.Request.Context.Authentication.SignIn(cookiesIdentity); 65 | } 66 | } 67 | 68 | public override Task TokenEndpoint(OAuthTokenEndpointContext context) 69 | { 70 | foreach (var property in context.Properties.Dictionary) 71 | { 72 | context.AdditionalResponseParameters.Add(property.Key, property.Value); 73 | } 74 | 75 | return Task.FromResult(null); 76 | } 77 | 78 | public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) 79 | { 80 | // Resource owner password credentials does not provide a client ID. 81 | if (context.ClientId == null) 82 | { 83 | context.Validated(); 84 | } 85 | 86 | return Task.FromResult(null); 87 | } 88 | 89 | public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context) 90 | { 91 | if (context.ClientId == this.publicClientId) 92 | { 93 | var expectedRootUri = new Uri(context.Request.Uri, "/"); 94 | 95 | if (expectedRootUri.AbsoluteUri == context.RedirectUri) 96 | { 97 | context.Validated(); 98 | } 99 | } 100 | 101 | return Task.FromResult(null); 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNet.Identity; 2 | using Microsoft.AspNet.Identity.Owin; 3 | using Microsoft.Owin; 4 | using Microsoft.Owin.Security.OAuth; 5 | using Owin; 6 | using System; 7 | using System.Web; 8 | using XperiAndri.AspNet.Identity.DbFirst; 9 | using XperiAndri.AspNet.Identity.DbFirst.Security; 10 | using XperiAndri.AspNet.Identity.EntityFramework.Identity; 11 | using XperiAndri.AspNet.Identity.EntityFramework.Models; 12 | 13 | [assembly: OwinStartup(typeof(Startup))] 14 | 15 | namespace XperiAndri.AspNet.Identity.DbFirst 16 | { 17 | public class Startup 18 | { 19 | public void Configuration(IAppBuilder app) 20 | { 21 | // Register UserManager in ApplicationDbContext in OWIN context 22 | app.CreatePerOwinContext(() => new ApplicationDbContext()); 23 | app.CreatePerOwinContext>( 24 | (IdentityFactoryOptions> options, IOwinContext context) => 25 | new UserManager(new UserStore(context.Get()))); 26 | 27 | // Enable the application to use bearer tokens to authenticate users 28 | app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions 29 | { 30 | TokenEndpointPath = new PathString("/token"), 31 | Provider = new ApplicationOAuthProvider( 32 | "self", () => HttpContext.Current.GetOwinContext().GetUserManager>()), 33 | AuthorizeEndpointPath = new PathString("/api/account/authorize"), 34 | AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), 35 | AllowInsecureHttp = true 36 | }); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/app.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | angular.module('app', ['ngRoute']) 4 | 5 | .config(function ($routeProvider) { 6 | $routeProvider 7 | .when('/', { templateUrl: '/home' }) 8 | .when('/about', { templateUrl: '/about' }) 9 | .when('/page-not-found', { templateUrl: '/page-not-found' }) 10 | .when('/login', { templateUrl: '/login', controller: 'LoginCtrl' }) 11 | .otherwise({ redirectTo: '/page-not-found' }); 12 | }) 13 | 14 | .controller('MainCtrl', function ($scope, $rootScope, $location) { 15 | $scope.logout = function () { 16 | $rootScope.token = null; 17 | $location.path('/'); 18 | }; 19 | }) 20 | 21 | .controller('LoginCtrl', function ($scope, $rootScope, $http, $location) { 22 | 23 | // Sample credentials 24 | $scope.username = 'user'; 25 | $scope.password = 'Passw0rd'; 26 | 27 | $scope.login = function (username, password) { 28 | $http({ 29 | method: 'POST', 30 | url: '/token', 31 | data: 'grant_type=password&username=' + encodeURIComponent(username) + 32 | '&password=' + encodeURIComponent(password), 33 | headers: { 'Content-Type': 'application/x-www-form-urlencoded' } 34 | }).success(function (data) { 35 | $rootScope.token = data; 36 | $location.path('/'); 37 | }); 38 | }; 39 | }); -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ASP.NET Identity Demo 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 35 | 36 |
37 | 38 | 43 | 44 | 48 | 49 | 54 | 55 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /examples/XperiAndri.AspNet.Identity.DbFirst/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/Asp.NetIdentity.vstemplate: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ASP.NET Identity Guid Key Database 5 | SQL Database project template for ASP.NET Identity 2 with GUID key columns. 6 | TemplateIcon.ico 7 | SQLDB 8 | 1000 9 | 46c64127-637c-46d1-9aa6-137ea25760eb 10 | true 11 | IdentityDatabase 12 | true 13 | 14 | 15 | 16 | 17 | 18 | Local.publish.xml 19 | 20 | 21 | RolesOfUsers.sql 22 | UserRoles.sql 23 | Users.sql 24 | 25 | 26 | PostDeployment.sql 27 | 28 | 29 | RolesOfUsers.sql 30 | UserClaims.sql 31 | UserLogins.sql 32 | UserRoles.sql 33 | Users.sql 34 | 35 | 36 | Email.sql 37 | Flag.sql 38 | Name.sql 39 | Phone.sql 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | ASPNET Identity Guidbased Database 4 | ASPNET Identity 2.0 Database template with Guid ids 5 | SQLDB 6 | 7 | 8 | 1000 9 | true 10 | ASPNET Identity Guidbased Database 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | 19 | 20 | Local.publish.xml 21 | 22 | 23 | RolesOfUsers.sql 24 | UserRoles.sql 25 | Users.sql 26 | 27 | 28 | PostDeployment.sql 29 | 30 | 31 | RolesOfUsers.sql 32 | UserClaims.sql 33 | UserLogins.sql 34 | UserRoles.sql 35 | Users.sql 36 | 37 | 38 | Email.sql 39 | Flag.sql 40 | Name.sql 41 | Phone.sql 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET Identity Guidbased Database")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET Identity Guidbased Database")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4e9112c3-4e96-4911-bc40-716cd649d836")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/Publish Profiles/Local.publish.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | $projectname$ 6 | $projectname$.sql 7 | Data Source=(LocalDb)\ProjectsV12;Integrated Security=True;Pooling=False;Connect Timeout=30 8 | True 9 | True 10 | 1 11 | 12 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/TemplateIcon.ico -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.DatabaseTemplate/XperiAndri.AspNetIdentity.Database.sqlproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | $safeprojectname$.Database 8 | 2.0 9 | 4.1 10 | {c77afcbd-25b7-4500-92dc-1248edd6a89e} 11 | Microsoft.Data.Tools.Schema.Sql.Sql110DatabaseSchemaProvider 12 | Database 13 | 14 | 15 | $safeprojectname$.Database 16 | $safeprojectname$.Database 17 | 1033, CI 18 | BySchemaAndSchemaType 19 | True 20 | v4.5.1 21 | CS 22 | Properties 23 | False 24 | True 25 | True 26 | 27 | 28 | bin\Release\ 29 | $(MSBuildProjectName).sql 30 | False 31 | pdbonly 32 | true 33 | false 34 | true 35 | prompt 36 | 4 37 | 38 | 39 | bin\Debug\ 40 | $(MSBuildProjectName).sql 41 | false 42 | true 43 | full 44 | false 45 | true 46 | true 47 | prompt 48 | 4 49 | 50 | 51 | 11.0 52 | 53 | True 54 | 11.0 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | DoNotCopy 85 | 86 | 87 | 88 | DoNotCopy 89 | 90 | 91 | DoNotCopy 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Linq; 3 | 4 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 5 | { 6 | internal class Constants 7 | { 8 | internal const string IdentityCategory = "ASP.NET Identity"; 9 | 10 | internal static readonly string aspNetIdentityNamespace = "http://schemas.xperiandri.com/AspNetIdentity"; 11 | internal static XName aspNetIdentityUserName = XName.Get("AspNetIdentityUser", aspNetIdentityNamespace); 12 | internal static XName aspNetIdentityUserRoleName = XName.Get("AspNetIdentityUserRole", aspNetIdentityNamespace); 13 | internal static XName aspNetIdentityUserLoginName = XName.Get("AspNetIdentityUserLogin", aspNetIdentityNamespace); 14 | internal static XName aspNetIdentityUserClaimName = XName.Get("AspNetIdentityUserClaim", aspNetIdentityNamespace); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityProperties.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing.Design; 6 | using System.Linq; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | internal class IdentityEntityProperties 12 | { 13 | private readonly PropertyManager propertyManager; 14 | private readonly XElement parent; 15 | private readonly PropertyExtensionContext context; 16 | 17 | public IdentityEntityProperties(XElement parent, PropertyExtensionContext context) 18 | { 19 | this.propertyManager = new PropertyManager(parent.GetDefaultNamespace()); 20 | this.context = context; 21 | this.parent = parent; 22 | this.parent.Changed += parentChanged; 23 | } 24 | 25 | void parentChanged(object sender, XObjectChangeEventArgs e) 26 | { 27 | var change = e.ObjectChange; 28 | } 29 | 30 | [DisplayName("User Entity Type")] 31 | [Description("An entity type which describes ASP.NET identity user.")] 32 | [Category(Constants.IdentityCategory)] 33 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 34 | public XElement UserEntity 35 | { 36 | get { return getValue(Constants.aspNetIdentityUserName); } 37 | set { setValue(Constants.aspNetIdentityUserName, value); } 38 | } 39 | 40 | [DisplayName("Role Entity Type")] 41 | [Description("An entity type which describes ASP.NET identity role.")] 42 | [Category(Constants.IdentityCategory)] 43 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 44 | public XElement RoleEntity 45 | { 46 | get { return getValue(Constants.aspNetIdentityUserRoleName); } 47 | set { setValue(Constants.aspNetIdentityUserRoleName, value); } 48 | } 49 | 50 | [DisplayName("User Login Entity Type")] 51 | [Description("An entity type which describes ASP.NET identity user login.")] 52 | [Category(Constants.IdentityCategory)] 53 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 54 | public XElement UserLoginEntity 55 | { 56 | get { return getValue(Constants.aspNetIdentityUserRoleName); } 57 | set { setValue(Constants.aspNetIdentityUserLoginName, value); } 58 | } 59 | 60 | [DisplayName("User Claim Entity Type")] 61 | [Description("An entity type which describes ASP.NET identity user claim.")] 62 | [Category(Constants.IdentityCategory)] 63 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 64 | public XElement UserClaimEntity 65 | { 66 | get { return getValue(Constants.aspNetIdentityUserClaimName); } 67 | set { setValue(Constants.aspNetIdentityUserClaimName, value); } 68 | } 69 | 70 | protected XElement getValue(XName name) 71 | { 72 | return propertyManager.GetValue(parent, name); 73 | } 74 | 75 | protected void setValue(XName name, XElement value) 76 | { 77 | propertyManager.SetValue(parent, context, name, value); 78 | } 79 | 80 | } 81 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityPropertiesFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System.ComponentModel.Composition; 3 | using System.Xml.Linq; 4 | 5 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 6 | { 7 | [PartCreationPolicy(CreationPolicy.Shared)] 8 | [Export(typeof(IEntityDesignerExtendedProperty))] 9 | [EntityDesignerExtendedProperty(EntityDesignerSelection.DesignerSurface)] 10 | class IdentityEntityPropertiesFactory : IEntityDesignerExtendedProperty 11 | { 12 | /// 13 | /// Called when the selected object in the Entity Data Model Designer 14 | /// changes and the new selection matches the object specified by the 15 | /// EntityDesignerExtendedProperty attribute. 16 | /// 17 | /// 18 | /// 19 | /// 20 | public object CreateProperty(XElement element, PropertyExtensionContext context) 21 | { 22 | return new IdentityEntityProperties(element, context); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityPropertyEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.Design; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Xml.Linq; 10 | 11 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 12 | { 13 | public class IdentityEntityPropertyEditor : ObjectSelectorEditor 14 | { 15 | private static readonly PropertyInfo wrappedItemProperty; 16 | private static readonly PropertyInfo xElementProperty; 17 | 18 | static IdentityEntityPropertyEditor() 19 | { 20 | Type efEntityModelDescriptorType = Type.GetType("Microsoft.Data.Entity.Design.UI.ViewModels.PropertyWindow.Descriptors.EFEntityModelDescriptor, Microsoft.Data.Entity.Design", true); 21 | wrappedItemProperty = efEntityModelDescriptorType.GetProperty("WrappedItem"); 22 | Type conceptualEntityModelType = Type.GetType("Microsoft.Data.Entity.Design.Model.Entity.ConceptualEntityModel, Microsoft.Data.Entity.Design.Model", true); 23 | xElementProperty = conceptualEntityModelType.GetProperty("XObject", BindingFlags.NonPublic | BindingFlags.Instance); 24 | } 25 | 26 | protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider) 27 | { 28 | base.FillTreeWithData(selector, context, provider); 29 | 30 | var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement; 31 | 32 | selector.AddNode("(None)", null, null); 33 | foreach (XElement entityType in new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model)) 34 | { 35 | selector.AddNode(entityType.Attribute("Name").Value, entityType, null); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/ModelGenerationExtension.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.Data.Entity.Design.Extensibility; 3 | using System; 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | [PartCreationPolicy(CreationPolicy.Shared)] 12 | [Export(typeof(IModelGenerationExtension))] 13 | class ModelGenerationExtension : IModelGenerationExtension 14 | { 15 | 16 | /* This callbacks only appears to be called by the Update Wizard*/ 17 | 18 | /// 19 | /// Called when the selected object in the Entity Data Model Designer changes 20 | /// and matches the specified EntityDesignerExtendedProperty attribute. 21 | /// 22 | /// Provides file and Visual Studio project information. 23 | void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context) 24 | { 25 | // 26 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this document. 27 | // Note that the document may have been modified by another extension's 28 | // implementation of OnAfterModelGenerated(). 29 | // 30 | // context.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or 31 | // the Update Model Wizard. An extension cannot modify this document. 32 | // 33 | // context.Project = The EnvDTE.Project that contains the .edmx file 34 | // 35 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 36 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 37 | // 38 | 39 | } 40 | 41 | /// 42 | /// Called after a model is updated by the Update Model Wizard. 43 | /// 44 | /// Provides file information and Visual Studio project information. 45 | void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) 46 | { 47 | // 48 | // context.OriginalDocument = The original XDocument before the Update Model Wizard started. 49 | // An extension cannot modify this document. 50 | // 51 | // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. 52 | // An extension cannot modify this document. 53 | // 54 | // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the 55 | // contents of context.GeneratedDocument. An extension cannot modify this document. 56 | // 57 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this 58 | // document. Note that the document may have been modified by another extension's implementation 59 | // of OnAfterModelGenerated(). 60 | // 61 | // 62 | // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. 63 | // 64 | // context.Project = The EnvDTE.Project that contains the .edmx file. 65 | // 66 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 67 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 68 | // 69 | 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/ModelTransformExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Xml.Linq; 6 | 7 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 8 | { 9 | [Export(typeof(IModelTransformExtension))] 10 | [PartCreationPolicy(CreationPolicy.Shared)] 11 | internal class ModelTransformExtension : IModelTransformExtension 12 | { 13 | /// 14 | /// Called after the .edmx document has been loaded, but before the contents are displayed in the 15 | /// Entity Designer. 16 | /// 17 | /// 18 | void IModelTransformExtension.OnAfterModelLoaded(ModelTransformExtensionContext context) 19 | { 20 | // context.OriginalDocument = The incoming .edmx document. 21 | // This file cannot be modified. 22 | // 23 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 24 | // This document will be loaded by the Entity Designer. 25 | 26 | XElement root = context.CurrentDocument.Root; 27 | string edmxNamespace = root.Name.NamespaceName; 28 | XElement runtime = root.Element(XName.Get("Runtime", edmxNamespace)); 29 | XElement conceptualModels = runtime.Element(XName.Get("ConceptualModels", edmxNamespace)); 30 | XElement schema = conceptualModels.Elements().FirstOrDefault(); 31 | XNamespace schemaNamespace = schema.GetDefaultNamespace(); 32 | } 33 | 34 | /// 35 | /// Called immediately before the .edmx document is saved. 36 | /// 37 | /// 38 | void IModelTransformExtension.OnBeforeModelSaved(ModelTransformExtensionContext context) 39 | { 40 | // context.OriginalDocument = The .edmx document as created by the Entity Designer. 41 | // 42 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 43 | // This should be the valid .edmx document to be saved. 44 | 45 | //context.CurrentDocument.Root.Elements(prop) 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EFDesignerExtension")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EFDesignerExtension")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("607a649f-3864-4f81-9a30-aee0cf5de5bb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/PropertyManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | internal class PropertyManager 12 | { 13 | private static readonly XName[] propertyNames = new XName[] 14 | { 15 | Constants.aspNetIdentityUserName, 16 | Constants.aspNetIdentityUserLoginName, 17 | Constants.aspNetIdentityUserRoleName, 18 | Constants.aspNetIdentityUserClaimName 19 | }; 20 | 21 | private readonly XName keyElementName; 22 | private readonly XName entityTypeName; 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public PropertyManager(string schema) 28 | { 29 | keyElementName = XName.Get("Key", schema); 30 | entityTypeName = XName.Get("EntityType", schema); 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class. 35 | /// 36 | public PropertyManager(XNamespace schema) : this(schema.NamespaceName) 37 | { 38 | } 39 | 40 | public XElement GetValue(XElement parent, XName name) 41 | { 42 | return GetEntityTypesWithIdentityElement(parent, name).FirstOrDefault(); 43 | } 44 | 45 | public void SetValue(XElement parent, PropertyExtensionContext context, XName name, XElement value) 46 | { 47 | if (value == null) 48 | { 49 | foreach (var element in GetEntityTypesWithIdentityElement(parent, name)) 50 | element.Element(name).Remove(); 51 | return; 52 | } 53 | 54 | var otherElements = (from element in value.Elements() 55 | let otherName = element.Name 56 | where propertyNames.Contains(otherName) && otherName != name 57 | select element).ToList(); 58 | if (otherElements.Any()) 59 | { 60 | DialogResult result = DialogResult.OK; 61 | if (GetEntityTypesWithIdentityElement(parent, otherName).Count() == 1) 62 | { 63 | string nameString = name.LocalName.Substring(name.LocalName.Length - 5, 4); 64 | string otherNameString = otherName.LocalName.Substring(otherName.LocalName.Length - 5, 4); 65 | string message = string.Format("Selected entity type is already used as a {0} identity. Would you like to set it as a {1} identity? A {0} identity will be unset.", otherName, name); 66 | string caption = string.Format("Entity is already in use as {0} identity!", otherName); 67 | result = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); 68 | } 69 | if (result == DialogResult.Cancel) 70 | return; 71 | else 72 | value.Element(otherName).Remove(); 73 | } 74 | 75 | using (EntityDesignerChangeScope scope = context.CreateChangeScope("Set ASP.NET Identity Property")) 76 | { 77 | foreach (var element in GetEntityTypesWithIdentityElement(parent, name)) 78 | { 79 | if (element != value) 80 | element.Element(name).Remove(); 81 | } 82 | 83 | if (value.Elements(name).Count() < 1) 84 | value.FirstNode.AddBeforeSelf(new XElement(name)); 85 | 86 | // Commit the changes. 87 | scope.Complete(); 88 | } 89 | } 90 | 91 | public IEnumerable GetEntityTypes(XElement schema) 92 | { 93 | return from entityType in schema.Elements(entityTypeName) 94 | where entityType.Elements(keyElementName).Any() 95 | select entityType; 96 | } 97 | 98 | public IEnumerable GetEntityTypesWithIdentityElement(XElement schema, XName identitElementName) 99 | { 100 | return from entityType in schema.Elements(entityTypeName) 101 | where entityType.Elements(identitElementName).Any() 102 | select entityType; 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/XperiAndri.AspNet.Identity.EFDesignerExtension.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B} 8 | Library 9 | Properties 10 | XperiAndri.AspNetIdentity.EFDesignerExtension 11 | XperiAndri.AspNetIdentity.EFDesignerExtension 12 | v4.5.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | True 35 | 36 | 37 | True 38 | 39 | 40 | True 41 | 42 | 43 | True 44 | 45 | 46 | 47 | ..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Microsoft.Data.Entity.Design.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Linq; 3 | 4 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 5 | { 6 | internal class Constants 7 | { 8 | internal const string IdentityCategory = "ASP.NET Identity"; 9 | 10 | internal static readonly string AspNetIdentityPrefix = "aspnetidentity"; 11 | internal static readonly string AspNetIdentityNamespace = "http://schemas.xperiandri.com/AspNetIdentity"; 12 | 13 | internal static XName aspNetIdentityAttributeName = XName.Get("AspNetIdentityType", AspNetIdentityNamespace); 14 | internal static XName aspNetIdentityUserName = XName.Get("AspNetIdentityUser", AspNetIdentityNamespace); 15 | internal static XName aspNetIdentityUserRoleName = XName.Get("AspNetIdentityUserRole", AspNetIdentityNamespace); 16 | internal static XName aspNetIdentityUserLoginName = XName.Get("AspNetIdentityUserLogin", AspNetIdentityNamespace); 17 | internal static XName aspNetIdentityUserClaimName = XName.Get("AspNetIdentityUserClaim", AspNetIdentityNamespace); 18 | } 19 | 20 | internal static class IdentityTypes 21 | { 22 | internal static readonly string User = "User"; 23 | internal static readonly string Login = "Login"; 24 | internal static readonly string Claim = "Claim"; 25 | internal static readonly string Role = "Role"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityProperties.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing.Design; 6 | using System.Linq; 7 | using System.Runtime.CompilerServices; 8 | using System.Xml.Linq; 9 | 10 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 11 | { 12 | internal class IdentityEntityProperties 13 | { 14 | private readonly PropertyManager propertyManager; 15 | private readonly XElement parent; 16 | private readonly PropertyExtensionContext context; 17 | 18 | public IdentityEntityProperties(XElement parent, PropertyExtensionContext context) 19 | { 20 | this.propertyManager = new PropertyManager(parent.GetDefaultNamespace()); 21 | this.context = context; 22 | this.parent = parent; 23 | this.parent.Changed += parentChanged; 24 | } 25 | 26 | void parentChanged(object sender, XObjectChangeEventArgs e) 27 | { 28 | var change = e.ObjectChange; 29 | } 30 | 31 | [DisplayName("User Entity")] 32 | [Description("An entity type which describes ASP.NET identity user.")] 33 | [Category(Constants.IdentityCategory)] 34 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 35 | public string UserEntity 36 | { 37 | get { return getValue(IdentityTypes.User); } 38 | set { setValue(IdentityTypes.User, value); } 39 | } 40 | 41 | [DisplayName("Role Entity")] 42 | [Description("An entity type which describes ASP.NET identity user role.")] 43 | [Category(Constants.IdentityCategory)] 44 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 45 | public string UserRoleEntity 46 | { 47 | get { return getValue(IdentityTypes.Role); } 48 | set { setValue(IdentityTypes.Role, value); } 49 | } 50 | 51 | [DisplayName("Login Entity")] 52 | [Description("An entity type which describes ASP.NET identity user login.")] 53 | [Category(Constants.IdentityCategory)] 54 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 55 | public string UserLoginEntity 56 | { 57 | get { return getValue(IdentityTypes.Login); } 58 | set { setValue(IdentityTypes.Login, value); } 59 | } 60 | 61 | [DisplayName("Claim Entity")] 62 | [Description("An entity type which describes ASP.NET identity user claim.")] 63 | [Category(Constants.IdentityCategory)] 64 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 65 | public string UserClaimEntity 66 | { 67 | get { return getValue(IdentityTypes.Claim); } 68 | set { setValue(IdentityTypes.Claim, value); } 69 | } 70 | 71 | protected string getValue(string identityType) 72 | { 73 | return propertyManager.GetValue(parent, identityType); 74 | } 75 | 76 | protected void setValue(string identityType, string entityName) 77 | { 78 | propertyManager.SetValue(parent, context, entityName, identityType); 79 | } 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityPropertiesFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System.ComponentModel.Composition; 3 | using System.Xml.Linq; 4 | 5 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 6 | { 7 | [PartCreationPolicy(CreationPolicy.Shared)] 8 | [Export(typeof(IEntityDesignerExtendedProperty))] 9 | [EntityDesignerExtendedProperty(EntityDesignerSelection.DesignerSurface)] 10 | class IdentityEntityPropertiesFactory : IEntityDesignerExtendedProperty 11 | { 12 | /// 13 | /// Called when the selected object in the Entity Data Model Designer 14 | /// changes and the new selection matches the object specified by the 15 | /// EntityDesignerExtendedProperty attribute. 16 | /// 17 | /// 18 | /// 19 | /// 20 | public object CreateProperty(XElement element, PropertyExtensionContext context) 21 | { 22 | return new IdentityEntityProperties(element, context); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityPropertyEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.Design; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Xml.Linq; 10 | 11 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 12 | { 13 | public class IdentityEntityPropertyEditor : ObjectSelectorEditor 14 | { 15 | private static readonly PropertyInfo wrappedItemProperty; 16 | private static readonly PropertyInfo xElementProperty; 17 | 18 | static IdentityEntityPropertyEditor() 19 | { 20 | Type efEntityModelDescriptorType = Type.GetType("Microsoft.Data.Entity.Design.UI.ViewModels.PropertyWindow.Descriptors.EFEntityModelDescriptor, Microsoft.Data.Entity.Design", true); 21 | wrappedItemProperty = efEntityModelDescriptorType.GetProperty("WrappedItem"); 22 | Type conceptualEntityModelType = Type.GetType("Microsoft.Data.Entity.Design.Model.Entity.ConceptualEntityModel, Microsoft.Data.Entity.Design.Model", true); 23 | xElementProperty = conceptualEntityModelType.GetProperty("XObject", BindingFlags.NonPublic | BindingFlags.Instance); 24 | } 25 | 26 | protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider) 27 | { 28 | base.FillTreeWithData(selector, context, provider); 29 | 30 | var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement; 31 | 32 | selector.AddNode("(None)", null, null); 33 | var items = new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model).Select(et => et.Attribute("Name").Value).OrderBy(n => n).ToList(); 34 | foreach (string entityTypeName in items) 35 | { 36 | selector.AddNode(entityTypeName, entityTypeName, null); 37 | } 38 | 39 | //int nOfItems = selector.Height / selector.ItemHeight; 40 | selector.Height = selector.ItemHeight * Math.Min(items.Count + 1, 8); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/ModelGenerationExtension.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.Data.Entity.Design.Extensibility; 3 | using System; 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | [PartCreationPolicy(CreationPolicy.Shared)] 12 | [Export(typeof(IModelGenerationExtension))] 13 | class ModelGenerationExtension : IModelGenerationExtension 14 | { 15 | 16 | /* This callbacks only appears to be called by the Update Wizard*/ 17 | 18 | /// 19 | /// Called when the selected object in the Entity Data Model Designer changes 20 | /// and matches the specified EntityDesignerExtendedProperty attribute. 21 | /// 22 | /// Provides file and Visual Studio project information. 23 | void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context) 24 | { 25 | // 26 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this document. 27 | // Note that the document may have been modified by another extension's 28 | // implementation of OnAfterModelGenerated(). 29 | // 30 | // context.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or 31 | // the Update Model Wizard. An extension cannot modify this document. 32 | // 33 | // context.Project = The EnvDTE.Project that contains the .edmx file 34 | // 35 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 36 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 37 | // 38 | 39 | } 40 | 41 | /// 42 | /// Called after a model is updated by the Update Model Wizard. 43 | /// 44 | /// Provides file information and Visual Studio project information. 45 | void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) 46 | { 47 | // 48 | // context.OriginalDocument = The original XDocument before the Update Model Wizard started. 49 | // An extension cannot modify this document. 50 | // 51 | // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. 52 | // An extension cannot modify this document. 53 | // 54 | // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the 55 | // contents of context.GeneratedDocument. An extension cannot modify this document. 56 | // 57 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this 58 | // document. Note that the document may have been modified by another extension's implementation 59 | // of OnAfterModelGenerated(). 60 | // 61 | // 62 | // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. 63 | // 64 | // context.Project = The EnvDTE.Project that contains the .edmx file. 65 | // 66 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 67 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 68 | // 69 | 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/ModelTransformExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Xml.Linq; 6 | 7 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 8 | { 9 | [Export(typeof(IModelTransformExtension))] 10 | [PartCreationPolicy(CreationPolicy.Shared)] 11 | internal class ModelTransformExtension : IModelTransformExtension 12 | { 13 | /// 14 | /// Called after the .edmx document has been loaded, but before the contents are displayed in the 15 | /// Entity Designer. 16 | /// 17 | /// 18 | void IModelTransformExtension.OnAfterModelLoaded(ModelTransformExtensionContext context) 19 | { 20 | // context.OriginalDocument = The incoming .edmx document. 21 | // This file cannot be modified. 22 | // 23 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 24 | // This document will be loaded by the Entity Designer. 25 | 26 | XElement root = context.CurrentDocument.Root; 27 | string edmxNamespace = root.Name.NamespaceName; 28 | XElement runtime = root.Element(XName.Get("Runtime", edmxNamespace)); 29 | XElement conceptualModels = runtime.Element(XName.Get("ConceptualModels", edmxNamespace)); 30 | XElement schema = conceptualModels.Elements().FirstOrDefault(); 31 | XNamespace schemaNamespace = schema.GetDefaultNamespace(); 32 | } 33 | 34 | /// 35 | /// Called immediately before the .edmx document is saved. 36 | /// 37 | /// 38 | void IModelTransformExtension.OnBeforeModelSaved(ModelTransformExtensionContext context) 39 | { 40 | // context.OriginalDocument = The .edmx document as created by the Entity Designer. 41 | // 42 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 43 | // This should be the valid .edmx document to be saved. 44 | 45 | //context.CurrentDocument.Root.Elements(prop) 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EFDesignerExtension")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EFDesignerExtension")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("607a649f-3864-4f81-9a30-aee0cf5de5bb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EFDesignerExtension/XperiAndri.AspNet.Identity.EFDesignerExtension.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B} 8 | Library 9 | Properties 10 | XperiAndri.AspNetIdentity.EFDesignerExtension 11 | XperiAndri.AspNetIdentity.EFDesignerExtension 12 | v4.5.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | True 35 | 36 | 37 | True 38 | 39 | 40 | True 41 | 42 | 43 | True 44 | 45 | 46 | 47 | C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Microsoft.Data.Entity.Design.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EntitiesTemplate/ADONETArtifactGenerator_AspNetIdentityClasses.vstemplate: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | ASP.NET Identity Entity and Store classes 9 | Template which generates classes from EntityFramework data model implementing interfaces required by ASP.NET Identity. 10 | 11 | c90af61e-cabd-4890-9f95-60361a21b527 12 | CSharp 13 | 4.0 14 | 1 15 | 10 16 | AspNetIdentity.tt 17 | 18 | 19 | 20 | 21 | 22 | System 23 | 24 | 25 | AspNetIdentity.tt 26 | Resources.resx 27 | 28 | 29 | 30 | 31 | NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 32 | NuGet.VisualStudio.TemplateWizard 33 | 34 | 35 | 36 | Microsoft.Data.Entity.Design, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 37 | Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.AddArtifactGeneratorWizard 38 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EntitiesTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET Identity GUID Entities Template")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET Identity GUID Entities Template")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("edca48a0-70d2-44b6-a9d4-93ca8b2b0bc5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.EntitiesTemplate/TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates12/XperiAndri.AspNet.Identity.EntitiesTemplate/TemplateIcon.ico -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.Package/PackageIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates12/XperiAndri.AspNet.Identity.Package/PackageIcon.ico -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.Package/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET_Identity_Guid_Key_Database_Package")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET_Identity_Guid_Key_Database_Package")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.Package/Source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ASP.NET Identity tools for Entity Framework model 6 | This package contains a set of tools and templates to simplify usage of Entity Framework data model with ASP.NET Identity: 7 | Entity Framework designer extension 8 | Item template for ASP.NET Identity objects generation 9 | SQL Database project template for ASP.NET Identity 2.0 with GUID key columns 10 | https://github.com/xperiandri/AspNet.Identity 11 | LICENSE.txt 12 | https://github.com/xperiandri/AspNet.Identity/blob/master/docs/Database-First.md 13 | PackageIcon.ico 14 | Database, ASP.NET, SSDT, ASP.NET Identity, SQL Database, GUID 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Templates12/XperiAndri.AspNet.Identity.Vsix.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.DatabaseTemplate", "XperiAndri.AspNet.Identity.DatabaseTemplate\XperiAndri.AspNet.Identity.DatabaseTemplate.csproj", "{986551AB-67E4-49E3-838A-04B9746DC495}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.Package", "XperiAndri.AspNet.Identity.Package\XperiAndri.AspNet.Identity.Package.csproj", "{6BAC2720-22D7-46AA-B8A1-0544DA05861D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EntitiesTemplate", "XperiAndri.AspNet.Identity.EntitiesTemplate\XperiAndri.AspNet.Identity.EntitiesTemplate.csproj", "{4952F6B5-A3CC-44DD-9950-920EA59A518D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EFDesignerExtension", "XperiAndri.AspNet.Identity.EFDesignerExtension\XperiAndri.AspNet.Identity.EFDesignerExtension.csproj", "{F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {986551AB-67E4-49E3-838A-04B9746DC495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {986551AB-67E4-49E3-838A-04B9746DC495}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {986551AB-67E4-49E3-838A-04B9746DC495}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {986551AB-67E4-49E3-838A-04B9746DC495}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(CodealikeProperties) = postSolution 41 | SolutionGuid = 00ed361c-382d-4ca3-a0b1-65c92491ceda 42 | EndGlobalSection 43 | GlobalSection(CodealikeProperties) = postSolution 44 | SolutionGuid = 02bdab8d-8764-4a38-bae6-2fd76b61c44c 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/Asp.NetIdentity.vstemplate: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ASP.NET Identity Guid Key Database 5 | SQL Database project template for ASP.NET Identity 2 with GUID key columns. 6 | TemplateIcon.ico 7 | SQLDB 8 | 1000 9 | 46c64127-637c-46d1-9aa6-137ea25760eb 10 | true 11 | IdentityDatabase 12 | true 13 | 14 | 15 | 16 | 17 | 18 | Local.publish.xml 19 | 20 | 21 | RolesOfUsers.sql 22 | UserRoles.sql 23 | Users.sql 24 | 25 | 26 | PostDeployment.sql 27 | 28 | 29 | RolesOfUsers.sql 30 | UserClaims.sql 31 | UserLogins.sql 32 | UserRoles.sql 33 | Users.sql 34 | 35 | 36 | Email.sql 37 | Flag.sql 38 | Name.sql 39 | Phone.sql 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | ASPNET Identity Guidbased Database 4 | ASPNET Identity 2.0 Database template with Guid ids 5 | SQLDB 6 | 7 | 8 | 1000 9 | true 10 | ASPNET Identity Guidbased Database 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | 19 | 20 | Local.publish.xml 21 | 22 | 23 | RolesOfUsers.sql 24 | UserRoles.sql 25 | Users.sql 26 | 27 | 28 | PostDeployment.sql 29 | 30 | 31 | RolesOfUsers.sql 32 | UserClaims.sql 33 | UserLogins.sql 34 | UserRoles.sql 35 | Users.sql 36 | 37 | 38 | Email.sql 39 | Flag.sql 40 | Name.sql 41 | Phone.sql 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET Identity Guidbased Database")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET Identity Guidbased Database")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4e9112c3-4e96-4911-bc40-716cd649d836")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/Publish Profiles/Local.publish.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | $projectname$ 6 | $projectname$.sql 7 | Data Source=(LocalDb)\ProjectsV12;Integrated Security=True;Pooling=False;Connect Timeout=30 8 | True 9 | True 10 | 1 11 | 12 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/TemplateIcon.ico -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.DatabaseTemplate/XperiAndri.AspNetIdentity.Database.sqlproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | $safeprojectname$.Database 8 | 2.0 9 | 4.1 10 | {c77afcbd-25b7-4500-92dc-1248edd6a89e} 11 | Microsoft.Data.Tools.Schema.Sql.Sql110DatabaseSchemaProvider 12 | Database 13 | 14 | 15 | $safeprojectname$.Database 16 | $safeprojectname$.Database 17 | 1033, CI 18 | BySchemaAndSchemaType 19 | True 20 | v4.6 21 | CS 22 | Properties 23 | False 24 | True 25 | True 26 | 27 | 28 | bin\Release\ 29 | $(MSBuildProjectName).sql 30 | False 31 | pdbonly 32 | true 33 | false 34 | true 35 | prompt 36 | 4 37 | 38 | 39 | bin\Debug\ 40 | $(MSBuildProjectName).sql 41 | false 42 | true 43 | full 44 | false 45 | true 46 | true 47 | prompt 48 | 4 49 | 50 | 51 | 11.0 52 | 53 | True 54 | 11.0 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | DoNotCopy 85 | 86 | 87 | 88 | DoNotCopy 89 | 90 | 91 | DoNotCopy 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Linq; 3 | 4 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 5 | { 6 | internal class Constants 7 | { 8 | internal const string IdentityCategory = "ASP.NET Identity"; 9 | 10 | internal static readonly string aspNetIdentityNamespace = "http://schemas.xperiandri.com/AspNetIdentity"; 11 | internal static XName aspNetIdentityUserName = XName.Get("AspNetIdentityUser", aspNetIdentityNamespace); 12 | internal static XName aspNetIdentityUserRoleName = XName.Get("AspNetIdentityUserRole", aspNetIdentityNamespace); 13 | internal static XName aspNetIdentityUserLoginName = XName.Get("AspNetIdentityUserLogin", aspNetIdentityNamespace); 14 | internal static XName aspNetIdentityUserClaimName = XName.Get("AspNetIdentityUserClaim", aspNetIdentityNamespace); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityProperties.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing.Design; 6 | using System.Linq; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | internal class IdentityEntityProperties 12 | { 13 | private readonly PropertyManager propertyManager; 14 | private readonly XElement parent; 15 | private readonly PropertyExtensionContext context; 16 | 17 | public IdentityEntityProperties(XElement parent, PropertyExtensionContext context) 18 | { 19 | this.propertyManager = new PropertyManager(parent.GetDefaultNamespace()); 20 | this.context = context; 21 | this.parent = parent; 22 | this.parent.Changed += parentChanged; 23 | } 24 | 25 | void parentChanged(object sender, XObjectChangeEventArgs e) 26 | { 27 | var change = e.ObjectChange; 28 | } 29 | 30 | [DisplayName("User Entity Type")] 31 | [Description("An entity type which describes ASP.NET identity user.")] 32 | [Category(Constants.IdentityCategory)] 33 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 34 | public XElement UserEntity 35 | { 36 | get { return getValue(Constants.aspNetIdentityUserName); } 37 | set { setValue(Constants.aspNetIdentityUserName, value); } 38 | } 39 | 40 | [DisplayName("Role Entity Type")] 41 | [Description("An entity type which describes ASP.NET identity role.")] 42 | [Category(Constants.IdentityCategory)] 43 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 44 | public XElement RoleEntity 45 | { 46 | get { return getValue(Constants.aspNetIdentityUserRoleName); } 47 | set { setValue(Constants.aspNetIdentityUserRoleName, value); } 48 | } 49 | 50 | [DisplayName("User Login Entity Type")] 51 | [Description("An entity type which describes ASP.NET identity user login.")] 52 | [Category(Constants.IdentityCategory)] 53 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 54 | public XElement UserLoginEntity 55 | { 56 | get { return getValue(Constants.aspNetIdentityUserRoleName); } 57 | set { setValue(Constants.aspNetIdentityUserLoginName, value); } 58 | } 59 | 60 | [DisplayName("User Claim Entity Type")] 61 | [Description("An entity type which describes ASP.NET identity user claim.")] 62 | [Category(Constants.IdentityCategory)] 63 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 64 | public XElement UserClaimEntity 65 | { 66 | get { return getValue(Constants.aspNetIdentityUserClaimName); } 67 | set { setValue(Constants.aspNetIdentityUserClaimName, value); } 68 | } 69 | 70 | protected XElement getValue(XName name) 71 | { 72 | return propertyManager.GetValue(parent, name); 73 | } 74 | 75 | protected void setValue(XName name, XElement value) 76 | { 77 | propertyManager.SetValue(parent, context, name, value); 78 | } 79 | 80 | } 81 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityPropertiesFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System.ComponentModel.Composition; 3 | using System.Xml.Linq; 4 | 5 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 6 | { 7 | [PartCreationPolicy(CreationPolicy.Shared)] 8 | [Export(typeof(IEntityDesignerExtendedProperty))] 9 | [EntityDesignerExtendedProperty(EntityDesignerSelection.DesignerSurface)] 10 | class IdentityEntityPropertiesFactory : IEntityDesignerExtendedProperty 11 | { 12 | /// 13 | /// Called when the selected object in the Entity Data Model Designer 14 | /// changes and the new selection matches the object specified by the 15 | /// EntityDesignerExtendedProperty attribute. 16 | /// 17 | /// 18 | /// 19 | /// 20 | public object CreateProperty(XElement element, PropertyExtensionContext context) 21 | { 22 | return new IdentityEntityProperties(element, context); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/IdentityEntityPropertyEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.Design; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Xml.Linq; 10 | 11 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 12 | { 13 | public class IdentityEntityPropertyEditor : ObjectSelectorEditor 14 | { 15 | private static readonly PropertyInfo wrappedItemProperty; 16 | private static readonly PropertyInfo xElementProperty; 17 | 18 | static IdentityEntityPropertyEditor() 19 | { 20 | Type efEntityModelDescriptorType = Type.GetType("Microsoft.Data.Entity.Design.UI.ViewModels.PropertyWindow.Descriptors.EFEntityModelDescriptor, Microsoft.Data.Entity.Design", true); 21 | wrappedItemProperty = efEntityModelDescriptorType.GetProperty("WrappedItem"); 22 | Type conceptualEntityModelType = Type.GetType("Microsoft.Data.Entity.Design.Model.Entity.ConceptualEntityModel, Microsoft.Data.Entity.Design.Model", true); 23 | xElementProperty = conceptualEntityModelType.GetProperty("XObject", BindingFlags.NonPublic | BindingFlags.Instance); 24 | } 25 | 26 | protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider) 27 | { 28 | base.FillTreeWithData(selector, context, provider); 29 | 30 | var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement; 31 | 32 | selector.AddNode("(None)", null, null); 33 | foreach (XElement entityType in new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model)) 34 | { 35 | selector.AddNode(entityType.Attribute("Name").Value, entityType, null); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/ModelGenerationExtension.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.Data.Entity.Design.Extensibility; 3 | using System; 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | [PartCreationPolicy(CreationPolicy.Shared)] 12 | [Export(typeof(IModelGenerationExtension))] 13 | class ModelGenerationExtension : IModelGenerationExtension 14 | { 15 | 16 | /* This callbacks only appears to be called by the Update Wizard*/ 17 | 18 | /// 19 | /// Called when the selected object in the Entity Data Model Designer changes 20 | /// and matches the specified EntityDesignerExtendedProperty attribute. 21 | /// 22 | /// Provides file and Visual Studio project information. 23 | void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context) 24 | { 25 | // 26 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this document. 27 | // Note that the document may have been modified by another extension's 28 | // implementation of OnAfterModelGenerated(). 29 | // 30 | // context.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or 31 | // the Update Model Wizard. An extension cannot modify this document. 32 | // 33 | // context.Project = The EnvDTE.Project that contains the .edmx file 34 | // 35 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 36 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 37 | // 38 | 39 | } 40 | 41 | /// 42 | /// Called after a model is updated by the Update Model Wizard. 43 | /// 44 | /// Provides file information and Visual Studio project information. 45 | void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) 46 | { 47 | // 48 | // context.OriginalDocument = The original XDocument before the Update Model Wizard started. 49 | // An extension cannot modify this document. 50 | // 51 | // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. 52 | // An extension cannot modify this document. 53 | // 54 | // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the 55 | // contents of context.GeneratedDocument. An extension cannot modify this document. 56 | // 57 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this 58 | // document. Note that the document may have been modified by another extension's implementation 59 | // of OnAfterModelGenerated(). 60 | // 61 | // 62 | // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. 63 | // 64 | // context.Project = The EnvDTE.Project that contains the .edmx file. 65 | // 66 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 67 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 68 | // 69 | 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/ModelTransformExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Xml.Linq; 6 | 7 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 8 | { 9 | [Export(typeof(IModelTransformExtension))] 10 | [PartCreationPolicy(CreationPolicy.Shared)] 11 | internal class ModelTransformExtension : IModelTransformExtension 12 | { 13 | /// 14 | /// Called after the .edmx document has been loaded, but before the contents are displayed in the 15 | /// Entity Designer. 16 | /// 17 | /// 18 | void IModelTransformExtension.OnAfterModelLoaded(ModelTransformExtensionContext context) 19 | { 20 | // context.OriginalDocument = The incoming .edmx document. 21 | // This file cannot be modified. 22 | // 23 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 24 | // This document will be loaded by the Entity Designer. 25 | 26 | XElement root = context.CurrentDocument.Root; 27 | string edmxNamespace = root.Name.NamespaceName; 28 | XElement runtime = root.Element(XName.Get("Runtime", edmxNamespace)); 29 | XElement conceptualModels = runtime.Element(XName.Get("ConceptualModels", edmxNamespace)); 30 | XElement schema = conceptualModels.Elements().FirstOrDefault(); 31 | XNamespace schemaNamespace = schema.GetDefaultNamespace(); 32 | } 33 | 34 | /// 35 | /// Called immediately before the .edmx document is saved. 36 | /// 37 | /// 38 | void IModelTransformExtension.OnBeforeModelSaved(ModelTransformExtensionContext context) 39 | { 40 | // context.OriginalDocument = The .edmx document as created by the Entity Designer. 41 | // 42 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 43 | // This should be the valid .edmx document to be saved. 44 | 45 | //context.CurrentDocument.Root.Elements(prop) 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EFDesignerExtension")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EFDesignerExtension")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("607a649f-3864-4f81-9a30-aee0cf5de5bb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/PropertyManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | internal class PropertyManager 12 | { 13 | private static readonly XName[] propertyNames = new XName[] 14 | { 15 | Constants.aspNetIdentityUserName, 16 | Constants.aspNetIdentityUserLoginName, 17 | Constants.aspNetIdentityUserRoleName, 18 | Constants.aspNetIdentityUserClaimName 19 | }; 20 | 21 | private readonly XName keyElementName; 22 | private readonly XName entityTypeName; 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public PropertyManager(string schema) 28 | { 29 | keyElementName = XName.Get("Key", schema); 30 | entityTypeName = XName.Get("EntityType", schema); 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class. 35 | /// 36 | public PropertyManager(XNamespace schema) : this(schema.NamespaceName) 37 | { 38 | } 39 | 40 | public XElement GetValue(XElement parent, XName name) 41 | { 42 | return GetEntityTypesWithIdentityElement(parent, name).FirstOrDefault(); 43 | } 44 | 45 | public void SetValue(XElement parent, PropertyExtensionContext context, XName name, XElement value) 46 | { 47 | if (value == null) 48 | { 49 | foreach (var element in GetEntityTypesWithIdentityElement(parent, name)) 50 | element.Element(name).Remove(); 51 | return; 52 | } 53 | 54 | var otherElements = (from element in value.Elements() 55 | let otherName = element.Name 56 | where propertyNames.Contains(otherName) && otherName != name 57 | select element).ToList(); 58 | if (otherElements.Any()) 59 | { 60 | DialogResult result = DialogResult.OK; 61 | if (GetEntityTypesWithIdentityElement(parent, otherName).Count() == 1) 62 | { 63 | string nameString = name.LocalName.Substring(name.LocalName.Length - 5, 4); 64 | string otherNameString = otherName.LocalName.Substring(otherName.LocalName.Length - 5, 4); 65 | string message = string.Format("Selected entity type is already used as a {0} identity. Would you like to set it as a {1} identity? A {0} identity will be unset.", otherName, name); 66 | string caption = string.Format("Entity is already in use as {0} identity!", otherName); 67 | result = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); 68 | } 69 | if (result == DialogResult.Cancel) 70 | return; 71 | else 72 | value.Element(otherName).Remove(); 73 | } 74 | 75 | using (EntityDesignerChangeScope scope = context.CreateChangeScope("Set ASP.NET Identity Property")) 76 | { 77 | foreach (var element in GetEntityTypesWithIdentityElement(parent, name)) 78 | { 79 | if (element != value) 80 | element.Element(name).Remove(); 81 | } 82 | 83 | if (value.Elements(name).Count() < 1) 84 | value.FirstNode.AddBeforeSelf(new XElement(name)); 85 | 86 | // Commit the changes. 87 | scope.Complete(); 88 | } 89 | } 90 | 91 | public IEnumerable GetEntityTypes(XElement schema) 92 | { 93 | return from entityType in schema.Elements(entityTypeName) 94 | where entityType.Elements(keyElementName).Any() 95 | select entityType; 96 | } 97 | 98 | public IEnumerable GetEntityTypesWithIdentityElement(XElement schema, XName identitElementName) 99 | { 100 | return from entityType in schema.Elements(entityTypeName) 101 | where entityType.Elements(identitElementName).Any() 102 | select entityType; 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension – копія/XperiAndri.AspNet.Identity.EFDesignerExtension.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B} 8 | Library 9 | Properties 10 | XperiAndri.AspNetIdentity.EFDesignerExtension 11 | XperiAndri.AspNetIdentity.EFDesignerExtension 12 | v4.5.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | True 35 | 36 | 37 | True 38 | 39 | 40 | True 41 | 42 | 43 | True 44 | 45 | 46 | 47 | ..\..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Microsoft.Data.Entity.Design.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Linq; 3 | 4 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 5 | { 6 | internal class Constants 7 | { 8 | internal const string IdentityCategory = "ASP.NET Identity"; 9 | 10 | internal static readonly string AspNetIdentityPrefix = "aspnetidentity"; 11 | internal static readonly string AspNetIdentityNamespace = "http://schemas.xperiandri.com/AspNetIdentity"; 12 | 13 | internal static XName aspNetIdentityAttributeName = XName.Get("AspNetIdentityType", AspNetIdentityNamespace); 14 | } 15 | 16 | internal static class IdentityTypes 17 | { 18 | internal static readonly string User = "User"; 19 | internal static readonly string Login = "Login"; 20 | internal static readonly string Claim = "Claim"; 21 | internal static readonly string Role = "Role"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityProperties.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing.Design; 6 | using System.Linq; 7 | using System.Runtime.CompilerServices; 8 | using System.Xml.Linq; 9 | 10 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 11 | { 12 | internal class IdentityEntityProperties 13 | { 14 | private readonly PropertyManager propertyManager; 15 | private readonly XElement parent; 16 | private readonly PropertyExtensionContext context; 17 | 18 | public IdentityEntityProperties(XElement parent, PropertyExtensionContext context) 19 | { 20 | this.propertyManager = new PropertyManager(parent.GetDefaultNamespace()); 21 | this.context = context; 22 | this.parent = parent; 23 | this.parent.Changed += parentChanged; 24 | } 25 | 26 | void parentChanged(object sender, XObjectChangeEventArgs e) 27 | { 28 | var change = e.ObjectChange; 29 | } 30 | 31 | [DisplayName("User Entity")] 32 | [Description("An entity type which describes ASP.NET identity user.")] 33 | [Category(Constants.IdentityCategory)] 34 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 35 | public string UserEntity 36 | { 37 | get { return getValue(IdentityTypes.User); } 38 | set { setValue(IdentityTypes.User, value); } 39 | } 40 | 41 | [DisplayName("Role Entity")] 42 | [Description("An entity type which describes ASP.NET identity user role.")] 43 | [Category(Constants.IdentityCategory)] 44 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 45 | public string UserRoleEntity 46 | { 47 | get { return getValue(IdentityTypes.Role); } 48 | set { setValue(IdentityTypes.Role, value); } 49 | } 50 | 51 | [DisplayName("Login Entity")] 52 | [Description("An entity type which describes ASP.NET identity user login.")] 53 | [Category(Constants.IdentityCategory)] 54 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 55 | public string UserLoginEntity 56 | { 57 | get { return getValue(IdentityTypes.Login); } 58 | set { setValue(IdentityTypes.Login, value); } 59 | } 60 | 61 | [DisplayName("Claim Entity")] 62 | [Description("An entity type which describes ASP.NET identity user claim.")] 63 | [Category(Constants.IdentityCategory)] 64 | [Editor(typeof(IdentityEntityPropertyEditor), typeof(UITypeEditor))] 65 | public string UserClaimEntity 66 | { 67 | get { return getValue(IdentityTypes.Claim); } 68 | set { setValue(IdentityTypes.Claim, value); } 69 | } 70 | 71 | protected string getValue(string identityType) 72 | { 73 | return propertyManager.GetValue(parent, identityType); 74 | } 75 | 76 | protected void setValue(string identityType, string entityName) 77 | { 78 | propertyManager.SetValue(parent, context, entityName, identityType); 79 | } 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityPropertiesFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System.ComponentModel.Composition; 3 | using System.Xml.Linq; 4 | 5 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 6 | { 7 | [PartCreationPolicy(CreationPolicy.Shared)] 8 | [Export(typeof(IEntityDesignerExtendedProperty))] 9 | [EntityDesignerExtendedProperty(EntityDesignerSelection.DesignerSurface)] 10 | class IdentityEntityPropertiesFactory : IEntityDesignerExtendedProperty 11 | { 12 | /// 13 | /// Called when the selected object in the Entity Data Model Designer 14 | /// changes and the new selection matches the object specified by the 15 | /// EntityDesignerExtendedProperty attribute. 16 | /// 17 | /// 18 | /// 19 | /// 20 | public object CreateProperty(XElement element, PropertyExtensionContext context) 21 | { 22 | return new IdentityEntityProperties(element, context); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/IdentityEntityPropertyEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.Design; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Xml.Linq; 10 | 11 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 12 | { 13 | public class IdentityEntityPropertyEditor : ObjectSelectorEditor 14 | { 15 | private static readonly PropertyInfo wrappedItemProperty; 16 | private static readonly PropertyInfo xElementProperty; 17 | 18 | static IdentityEntityPropertyEditor() 19 | { 20 | Type efEntityModelDescriptorType = Type.GetType("Microsoft.Data.Entity.Design.UI.ViewModels.PropertyWindow.Descriptors.EFEntityModelDescriptor, Microsoft.Data.Entity.Design", true); 21 | wrappedItemProperty = efEntityModelDescriptorType.GetProperty("WrappedItem"); 22 | Type conceptualEntityModelType = Type.GetType("Microsoft.Data.Entity.Design.Model.Entity.ConceptualEntityModel, Microsoft.Data.Entity.Design.Model", true); 23 | xElementProperty = conceptualEntityModelType.GetProperty("XObject", BindingFlags.NonPublic | BindingFlags.Instance); 24 | } 25 | 26 | protected override void FillTreeWithData(Selector selector, ITypeDescriptorContext context, IServiceProvider provider) 27 | { 28 | base.FillTreeWithData(selector, context, provider); 29 | 30 | var model = xElementProperty.GetValue(wrappedItemProperty.GetValue(context.Instance)) as XElement; 31 | 32 | selector.AddNode("(None)", null, null); 33 | var items = new PropertyManager(model.GetDefaultNamespace()).GetEntityTypes(model).Select(et => et.Attribute("Name").Value).OrderBy(n => n).ToList(); 34 | foreach (string entityTypeName in items) 35 | { 36 | selector.AddNode(entityTypeName, entityTypeName, null); 37 | } 38 | 39 | int nOfItems = selector.Height / selector.ItemHeight; 40 | //selector.Height = selector.ItemHeight * Math.Min(items.Count + 1, 8); 41 | selector.Height = selector.ItemHeight * nOfItems; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/ModelGenerationExtension.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.Data.Entity.Design.Extensibility; 3 | using System; 4 | using System.ComponentModel.Composition; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | using System.Xml.Linq; 8 | 9 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 10 | { 11 | [PartCreationPolicy(CreationPolicy.Shared)] 12 | [Export(typeof(IModelGenerationExtension))] 13 | class ModelGenerationExtension : IModelGenerationExtension 14 | { 15 | 16 | /* This callbacks only appears to be called by the Update Wizard*/ 17 | 18 | /// 19 | /// Called when the selected object in the Entity Data Model Designer changes 20 | /// and matches the specified EntityDesignerExtendedProperty attribute. 21 | /// 22 | /// Provides file and Visual Studio project information. 23 | void IModelGenerationExtension.OnAfterModelGenerated(ModelGenerationExtensionContext context) 24 | { 25 | // 26 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this document. 27 | // Note that the document may have been modified by another extension's 28 | // implementation of OnAfterModelGenerated(). 29 | // 30 | // context.GeneratedDocument = The original XDocument that was generated Entity Data Model Wizard or 31 | // the Update Model Wizard. An extension cannot modify this document. 32 | // 33 | // context.Project = The EnvDTE.Project that contains the .edmx file 34 | // 35 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 36 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 37 | // 38 | 39 | } 40 | 41 | /// 42 | /// Called after a model is updated by the Update Model Wizard. 43 | /// 44 | /// Provides file information and Visual Studio project information. 45 | void IModelGenerationExtension.OnAfterModelUpdated(UpdateModelExtensionContext context) 46 | { 47 | // 48 | // context.OriginalDocument = The original XDocument before the Update Model Wizard started. 49 | // An extension cannot modify this document. 50 | // 51 | // context.GeneratedDocument = The XDocument that was generated by the Update Model wizard. 52 | // An extension cannot modify this document. 53 | // 54 | // context.UpdateModelDocument = The contents of context.OriginalDocument merged with the 55 | // contents of context.GeneratedDocument. An extension cannot modify this document. 56 | // 57 | // context.CurrentDocument = The XDocument that will be saved. An extension can modify this 58 | // document. Note that the document may have been modified by another extension's implementation 59 | // of OnAfterModelGenerated(). 60 | // 61 | // 62 | // context.ProjectItem = The EnvDTE.ProjectItem of current .edmx file. 63 | // 64 | // context.Project = The EnvDTE.Project that contains the .edmx file. 65 | // 66 | // context.WizardKind = The wizard that initiated the .edmx file generation or update process. 67 | // Possible values are WizardKind.Generate or WizardKind.UpdateModel. 68 | // 69 | 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/ModelTransformExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Entity.Design.Extensibility; 2 | using System; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Xml.Linq; 6 | 7 | namespace XperiAndri.AspNetIdentity.EFDesignerExtension 8 | { 9 | [Export(typeof(IModelTransformExtension))] 10 | [PartCreationPolicy(CreationPolicy.Shared)] 11 | internal class ModelTransformExtension : IModelTransformExtension 12 | { 13 | /// 14 | /// Called after the .edmx document has been loaded, but before the contents are displayed in the 15 | /// Entity Designer. 16 | /// 17 | /// 18 | void IModelTransformExtension.OnAfterModelLoaded(ModelTransformExtensionContext context) 19 | { 20 | // context.OriginalDocument = The incoming .edmx document. 21 | // This file cannot be modified. 22 | // 23 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 24 | // This document will be loaded by the Entity Designer. 25 | 26 | XElement root = context.CurrentDocument.Root; 27 | string edmxNamespace = root.Name.NamespaceName; 28 | XElement runtime = root.Element(XName.Get("Runtime", edmxNamespace)); 29 | XElement conceptualModels = runtime.Element(XName.Get("ConceptualModels", edmxNamespace)); 30 | XElement schema = conceptualModels.Elements().FirstOrDefault(); 31 | XNamespace schemaNamespace = schema.GetDefaultNamespace(); 32 | } 33 | 34 | /// 35 | /// Called immediately before the .edmx document is saved. 36 | /// 37 | /// 38 | void IModelTransformExtension.OnBeforeModelSaved(ModelTransformExtensionContext context) 39 | { 40 | // context.OriginalDocument = The .edmx document as created by the Entity Designer. 41 | // 42 | // context.CurrentDocument = Make changes to this document using OriginalDocument as a reference. 43 | // This should be the valid .edmx document to be saved. 44 | 45 | //context.CurrentDocument.Root.Elements(prop) 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EFDesignerExtension")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EFDesignerExtension")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("607a649f-3864-4f81-9a30-aee0cf5de5bb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EFDesignerExtension/XperiAndri.AspNet.Identity.EFDesignerExtension.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B} 8 | Library 9 | Properties 10 | XperiAndri.AspNetIdentity.EFDesignerExtension 11 | XperiAndri.AspNetIdentity.EFDesignerExtension 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | True 36 | 37 | 38 | True 39 | 40 | 41 | True 42 | 43 | 44 | True 45 | 46 | 47 | 48 | C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Microsoft.Data.Entity.Design.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 82 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EntitiesTemplate/ADONETArtifactGenerator_AspNetIdentityClasses.vstemplate: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | ASP.NET Identity Entity and Store classes 9 | Template which generates classes from EntityFramework data model implementing interfaces required by ASP.NET Identity. 10 | 11 | c90af61e-cabd-4890-9f95-60361a21b527 12 | CSharp 13 | 4.0 14 | 1 15 | 10 16 | AspNetIdentity.tt 17 | 18 | 19 | 20 | 21 | 22 | System 23 | 24 | 25 | AspNetIdentity.tt 26 | Resources.resx 27 | 28 | 29 | 30 | 31 | NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 32 | NuGet.VisualStudio.TemplateWizard 33 | 34 | 35 | 36 | Microsoft.Data.Entity.Design, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 37 | Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.AddArtifactGeneratorWizard 38 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EntitiesTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET Identity GUID Entities Template")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET Identity GUID Entities Template")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("edca48a0-70d2-44b6-a9d4-93ca8b2b0bc5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.EntitiesTemplate/TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates14/XperiAndri.AspNet.Identity.EntitiesTemplate/TemplateIcon.ico -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.Package/PackageIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xperiandri/Asp.Net-Identity-Tools-for-Entity-Framework-model/bed469458c0efe0e90b28b31d792acb5b19f23f0/src/Templates14/XperiAndri.AspNet.Identity.Package/PackageIcon.ico -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.Package/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ASP.NET_Identity_Guid_Key_Database_Package")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ASP.NET_Identity_Guid_Key_Database_Package")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.Package/Source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ASP.NET Identity tools for Entity Framework model 6 | This package contains a set of tools and templates to simplify usage of Entity Framework data model with ASP.NET Identity: 7 | Entity Framework designer extension 8 | Item template for ASP.NET Identity objects generation 9 | SQL Database project template for ASP.NET Identity 2.0 with GUID key columns 10 | https://github.com/xperiandri/AspNet.Identity 11 | LICENSE.txt 12 | https://github.com/xperiandri/AspNet.Identity/blob/master/docs/Database-First.md 13 | PackageIcon.ico 14 | Database, ASP.NET, SSDT, ASP.NET Identity, SQL Database, GUID 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Templates14/XperiAndri.AspNet.Identity.Vsix.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.22823.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.DatabaseTemplate", "XperiAndri.AspNet.Identity.DatabaseTemplate\XperiAndri.AspNet.Identity.DatabaseTemplate.csproj", "{986551AB-67E4-49E3-838A-04B9746DC495}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.Package", "XperiAndri.AspNet.Identity.Package\XperiAndri.AspNet.Identity.Package.csproj", "{6BAC2720-22D7-46AA-B8A1-0544DA05861D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EntitiesTemplate", "XperiAndri.AspNet.Identity.EntitiesTemplate\XperiAndri.AspNet.Identity.EntitiesTemplate.csproj", "{4952F6B5-A3CC-44DD-9950-920EA59A518D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XperiAndri.AspNet.Identity.EFDesignerExtension", "XperiAndri.AspNet.Identity.EFDesignerExtension\XperiAndri.AspNet.Identity.EFDesignerExtension.csproj", "{F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {986551AB-67E4-49E3-838A-04B9746DC495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {986551AB-67E4-49E3-838A-04B9746DC495}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {986551AB-67E4-49E3-838A-04B9746DC495}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {986551AB-67E4-49E3-838A-04B9746DC495}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {6BAC2720-22D7-46AA-B8A1-0544DA05861D}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {4952F6B5-A3CC-44DD-9950-920EA59A518D}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {F442FE9B-F0C8-46D1-BB4B-FDDC42F1745B}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(CodealikeProperties) = postSolution 41 | SolutionGuid = 00ed361c-382d-4ca3-a0b1-65c92491ceda 42 | EndGlobalSection 43 | GlobalSection(CodealikeProperties) = postSolution 44 | SolutionGuid = 02bdab8d-8764-4a38-bae6-2fd76b61c44c 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Publish Profiles/Local.publish.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | AspNetIdentity 6 | Database.sql 7 | Data Source=(LocalDb)\ProjectsV12;Integrated Security=True;Pooling=False;Connect Timeout=30 8 | True 9 | True 10 | 1 11 | 12 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Reference Data/RolesOfUsers.sql: -------------------------------------------------------------------------------- 1 | MERGE INTO [dbo].[RolesOfUsers] AS Target 2 | USING (VALUES 3 | 4 | (N'cad9d619-f270-444e-883f-181bdfc249a3', N'22c7a242-7810-4152-8088-f96aeb27b0d2') 5 | 6 | ) AS Source ([UserID], [RoleID]) 7 | ON Target.[UserId] = Source.[UserID] AND Target.[RoleId] = Source.[RoleID] 8 | WHEN NOT MATCHED BY TARGET THEN 9 | -- Insert new rows 10 | INSERT ([UserId], [RoleId]) 11 | VALUES ([UserID], [RoleID]); 12 | GO -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Reference Data/UserRoles.sql: -------------------------------------------------------------------------------- 1 | MERGE INTO [dbo].[UserRoles] AS Target 2 | USING (VALUES 3 | 4 | (N'22c7a242-7810-4152-8088-f96aeb27b0d2', N'Administrator'), 5 | (N'f77ebb1c-afbd-4ff1-906f-c567fa6cded0', N'Moderator') 6 | 7 | ) AS Source ([RoleID], [Name]) 8 | ON Target.[RoleId] = Source.[RoleID] 9 | -- Update matched rows 10 | WHEN MATCHED THEN 11 | UPDATE SET [Name] = Source.[Name] 12 | -- Insert new rows 13 | WHEN NOT MATCHED BY TARGET THEN 14 | INSERT ([RoleId], [Name]) 15 | VALUES ([RoleID], [Name]) 16 | -- Delete rows that are in the target but not the source 17 | WHEN NOT MATCHED BY SOURCE THEN 18 | DELETE; 19 | GO -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Reference Data/Users.sql: -------------------------------------------------------------------------------- 1 | MERGE INTO [dbo].[Users] AS Target 2 | USING (VALUES 3 | 4 | (N'cad9d619-f270-444e-883f-181bdfc249a3', N'admin', N'admin@example.com', 0, N'ACe+kHUdH61ms8NbkXSCXyV34CEP7tjfj93JrtlKRPfShGurFdAujQrmbVA7J9MDbg==', 5 | N'9771f91d-b4a0-45e0-8971-899b907c5863', NULL, 0, 0, NULL, 0, 0), 6 | (N'85245dac-2c43-49bc-bdfe-2f49a8de9d7b', N'demo', N'demo@example.com', 0, N'ACe+kHUdH61ms8NbkXSCXyV34CEP7tjfj93JrtlKRPfShGurFdAujQrmbVA7J9MDbg==', 7 | N'9771f91d-b4a0-45e0-8971-899b907c5863', NULL, 0, 0, NULL, 0, 0) 8 | 9 | ) AS Source ( 10 | [UserID], 11 | [UserName], 12 | [Email], 13 | [EmailConfirmed], 14 | [PasswordHash], 15 | [SecurityStamp], 16 | [PhoneNumber], 17 | [PhoneNumberConfirmed], 18 | [TwoFactorEnabled], 19 | [LockoutEndDateUtc], 20 | [LockoutEnabled], 21 | [AccessFailedCount] 22 | ) 23 | ON Target.[UserId] = Source.[UserID] 24 | -- Update matched rows 25 | WHEN MATCHED THEN 26 | UPDATE SET 27 | [UserName] = Source.[UserName], 28 | [Email] = Source.[Email], 29 | [EmailConfirmed] = Source.[EmailConfirmed], 30 | [PasswordHash] = Source.[PasswordHash], 31 | [SecurityStamp] = Source.[SecurityStamp], 32 | [PhoneNumber] = Source.[PhoneNumber], 33 | [PhoneNumberConfirmed] = Source.[PhoneNumberConfirmed], 34 | [TwoFactorEnabled] = Source.[TwoFactorEnabled], 35 | [LockoutEndDateUtc] = Source.[LockoutEndDateUtc], 36 | [LockoutEnabled] = Source.[LockoutEnabled], 37 | [AccessFailedCount] = Source.[AccessFailedCount] 38 | -- Insert new rows 39 | WHEN NOT MATCHED BY TARGET THEN 40 | INSERT ( 41 | [UserId], 42 | [UserName], 43 | [Email], 44 | [EmailConfirmed], 45 | [PasswordHash], 46 | [SecurityStamp], 47 | [PhoneNumber], 48 | [PhoneNumberConfirmed], 49 | [TwoFactorEnabled], 50 | [LockoutEndDateUtc], 51 | [LockoutEnabled], 52 | [AccessFailedCount] 53 | ) 54 | VALUES ( 55 | [UserID], 56 | [UserName], 57 | [Email], 58 | [EmailConfirmed], 59 | [PasswordHash], 60 | [SecurityStamp], 61 | [PhoneNumber], 62 | [PhoneNumberConfirmed], 63 | [TwoFactorEnabled], 64 | [LockoutEndDateUtc], 65 | [LockoutEnabled], 66 | [AccessFailedCount] 67 | ); 68 | GO 69 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Scripts/PostDeployment.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Post-Deployment Script Template 3 | -------------------------------------------------------------------------------------- 4 | This file contains SQL statements that will be appended to the build script. 5 | Use SQLCMD syntax to include a file in the post-deployment script. 6 | Example: :r .\myfile.sql 7 | Use SQLCMD syntax to reference a variable in the post-deployment script. 8 | Example: :setvar TableName MyTable 9 | SELECT * FROM [$(TableName)] 10 | -------------------------------------------------------------------------------------- 11 | */ 12 | 13 | :r "..\Reference Data\Users.sql" 14 | :r "..\Reference Data\UserRoles.sql" 15 | :r "..\Reference Data\RolesOfUsers.sql" 16 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Tables/RolesOfUsers.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[RolesOfUsers] 2 | ( 3 | [UserId] UNIQUEIDENTIFIER NOT NULL, 4 | [RoleId] UNIQUEIDENTIFIER NOT NULL, 5 | 6 | CONSTRAINT [PK_RolesOfUsers_UserID_RoleID] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC), 7 | CONSTRAINT [FK_RolesOfUsers_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([UserId]) ON DELETE CASCADE, 8 | CONSTRAINT [FK_RolesOfUsers_UserRole] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[UserRoles] ([RoleId]) ON DELETE CASCADE 9 | ); 10 | 11 | GO 12 | CREATE NONCLUSTERED INDEX [IX_RolesOfUsers_UserID] 13 | ON [dbo].[RolesOfUsers] ([UserId] ASC); 14 | 15 | GO 16 | CREATE NONCLUSTERED INDEX [IX_RolesOfUsers_RoleID] 17 | ON [dbo].[RolesOfUsers] ([RoleId] ASC); 18 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Tables/UserClaims.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UserClaims] 2 | ( 3 | [UserId] UNIQUEIDENTIFIER NOT NULL, 4 | [ClaimID] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), 5 | [ClaimType] NVARCHAR (MAX) NULL, 6 | [ClaimValue] NVARCHAR (MAX) NULL, 7 | 8 | CONSTRAINT [PK_UserClaims_ClaimID] PRIMARY KEY CLUSTERED ([ClaimID] ASC), 9 | CONSTRAINT [FK_UserClaims_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([UserId]) ON DELETE CASCADE 10 | ); 11 | 12 | GO 13 | CREATE NONCLUSTERED INDEX [IX_UserClaims_UserID] 14 | ON [dbo].[UserClaims] ([UserId] ASC); -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Tables/UserLogins.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UserLogins] 2 | ( 3 | [UserId] UNIQUEIDENTIFIER NOT NULL, 4 | [LoginProvider] NVARCHAR (128) NOT NULL, 5 | [ProviderKey] NVARCHAR (128) NOT NULL, 6 | 7 | CONSTRAINT [PK_UserLogins_UserID_LoginProvider_ProviderKey] PRIMARY KEY CLUSTERED ([UserId] ASC, [LoginProvider] ASC, [ProviderKey] ASC), 8 | CONSTRAINT [FK_UserLogins_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([UserId]) ON DELETE CASCADE 9 | ); 10 | 11 | GO 12 | CREATE NONCLUSTERED INDEX [IX_UserLogins_UserID] 13 | ON [dbo].[UserLogins] ([UserId] ASC); 14 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Tables/UserRoles.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[UserRoles] 2 | ( 3 | [RoleId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), 4 | [Name] [dbo].[Name] NOT NULL, 5 | 6 | CONSTRAINT [PK_UserRole_RoleID] PRIMARY KEY CLUSTERED ([RoleId] ASC), 7 | CONSTRAINT [UK_UserRole_Name] UNIQUE NONCLUSTERED ([Name] ASC) 8 | ); 9 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/Tables/Users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[Users] 2 | ( 3 | [UserId] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), 4 | [UserName] [dbo].[Name] NOT NULL, 5 | [Email] [dbo].[Email] NULL, 6 | [EmailConfirmed] [dbo].[Flag] NOT NULL, 7 | [PasswordHash] NVARCHAR (100) NULL, 8 | [SecurityStamp] NVARCHAR (100) NULL, 9 | [PhoneNumber] [dbo].[Phone] NULL, 10 | [PhoneNumberConfirmed] [dbo].[Flag] NOT NULL, 11 | [TwoFactorEnabled] [dbo].[Flag] NOT NULL, 12 | [LockoutEndDateUtc] DATETIME NULL, 13 | [LockoutEnabled] [dbo].[Flag] NOT NULL, 14 | [AccessFailedCount] INT NOT NULL, 15 | 16 | CONSTRAINT [PK_Users_UserID] PRIMARY KEY CLUSTERED ([UserId] ASC), 17 | CONSTRAINT [UK_Users_UserName] UNIQUE NONCLUSTERED ([UserName] ASC) 18 | ); 19 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/User Defined Types/Email.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[Email] 2 | FROM NVARCHAR (100) NULL; 3 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/User Defined Types/Flag.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[Flag] 2 | FROM BIT NOT NULL; 3 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/User Defined Types/Name.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[Name] 2 | FROM NVARCHAR (50) NOT NULL; 3 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/User Defined Types/Phone.sql: -------------------------------------------------------------------------------- 1 | CREATE TYPE [dbo].[Phone] 2 | FROM NVARCHAR (25) NULL; 3 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.Database/XperiAndri.AspNet.Identity.Database.sqlproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | XperiAndri.AspNet.Identity.Database 8 | 2.0 9 | 4.1 10 | {c77afcbd-25b7-4500-92dc-1248edd6a89e} 11 | Microsoft.Data.Tools.Schema.Sql.Sql110DatabaseSchemaProvider 12 | Database 13 | 14 | 15 | XperiAndri.AspNet.Identity.Database 16 | XperiAndri.AspNet.Identity.Database 17 | 1033, CI 18 | BySchemaAndSchemaType 19 | True 20 | v4.5.1 21 | CS 22 | Properties 23 | False 24 | True 25 | True 26 | 27 | 28 | bin\Release\ 29 | $(MSBuildProjectName).sql 30 | False 31 | pdbonly 32 | true 33 | false 34 | true 35 | prompt 36 | 4 37 | 38 | 39 | bin\Debug\ 40 | $(MSBuildProjectName).sql 41 | false 42 | true 43 | full 44 | false 45 | true 46 | true 47 | prompt 48 | 4 49 | 50 | 51 | 11.0 52 | 53 | True 54 | 11.0 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | DoNotCopy 85 | 86 | 87 | 88 | DoNotCopy 89 | 90 | 91 | DoNotCopy 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Identity/IdentityExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Principal; 5 | using System.Web; 6 | 7 | using Microsoft.AspNet.Identity; 8 | 9 | namespace XperiAndri.AspNet.Identity.EntityFramework.Identity 10 | { 11 | internal static class IdentityExtensions 12 | { 13 | public static Guid GetUserGuidId(this IIdentity identity) 14 | { 15 | return new Guid (identity.GetUserId()); 16 | } 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Identity/RoleStore.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) KriaSoft, LLC. All rights reserved. See LICENSE.txt in the project root for license information. 2 | 3 | using System; 4 | using System.Data.Entity; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | using Microsoft.AspNet.Identity; 9 | 10 | using XperiAndri.AspNet.Identity.EntityFramework; 11 | using XperiAndri.AspNet.Identity.EntityFramework.Models; 12 | 13 | namespace XperiAndri.AspNet.Identity.EntityFramework.Identity 14 | { 15 | public class RoleStore : IQueryableRoleStore 16 | { 17 | private readonly ApplicationDbContext db; 18 | 19 | public RoleStore(ApplicationDbContext db) 20 | { 21 | this.db = db; 22 | } 23 | 24 | //// IQueryableRoleStore 25 | 26 | public IQueryable Roles 27 | { 28 | get { return this.db.UserRoles; } 29 | } 30 | 31 | //// IRoleStore 32 | 33 | public virtual Task CreateAsync(UserRole role) 34 | { 35 | if (role == null) 36 | { 37 | throw new ArgumentNullException("role"); 38 | } 39 | 40 | this.db.UserRoles.Add(role); 41 | return this.db.SaveChangesAsync(); 42 | } 43 | 44 | public Task DeleteAsync(UserRole role) 45 | { 46 | if (role == null) 47 | { 48 | throw new ArgumentNullException("role"); 49 | } 50 | 51 | this.db.UserRoles.Remove(role); 52 | return this.db.SaveChangesAsync(); 53 | } 54 | 55 | public Task FindByIdAsync(Guid roleId) 56 | { 57 | return this.db.UserRoles.FindAsync(new[] { roleId }); 58 | } 59 | 60 | public Task FindByNameAsync(string roleName) 61 | { 62 | return this.db.UserRoles.FirstOrDefaultAsync(r => r.Name == roleName); 63 | } 64 | 65 | public Task UpdateAsync(UserRole role) 66 | { 67 | if (role == null) 68 | { 69 | throw new ArgumentNullException("role"); 70 | } 71 | 72 | this.db.Entry(role).State = EntityState.Modified; 73 | return this.db.SaveChangesAsync(); 74 | } 75 | 76 | //// IDisposable 77 | 78 | public void Dispose() 79 | { 80 | this.Dispose(true); 81 | GC.SuppressFinalize(this); 82 | } 83 | 84 | protected virtual void Dispose(bool disposing) 85 | { 86 | if (disposing && this.db != null) 87 | { 88 | this.db.Dispose(); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/IdentityModels.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNet.Identity.EntityFramework; 2 | 3 | namespace XperiAndri.AspNet.Identity.EntityFramework 4 | { 5 | // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. 6 | public class ApplicationUser : IdentityUser 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/Model.Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 11 | { 12 | using System; 13 | using System.Data.Entity; 14 | using System.Data.Entity.Infrastructure; 15 | 16 | public partial class ApplicationDbContext : DbContext 17 | { 18 | public ApplicationDbContext() 19 | : base("name=ApplicationDbContext") 20 | { 21 | } 22 | 23 | protected override void OnModelCreating(DbModelBuilder modelBuilder) 24 | { 25 | throw new UnintentionalCodeFirstException(); 26 | } 27 | 28 | public virtual DbSet UserClaims { get; set; } 29 | public virtual DbSet UserLogins { get; set; } 30 | public virtual DbSet UserRoles { get; set; } 31 | public virtual DbSet Users { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/Model.Designer.cs: -------------------------------------------------------------------------------- 1 | // T4 code generation is enabled for model 'C:\Users\Андрій\Dev\GitHub\AspNet.Identity\src\XperiAndri.AspNet.Identity.EntityFramework\Models\Model.edmx'. 2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer 3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model 4 | // is open in the designer. 5 | 6 | // If no context and entity classes have been generated, it may be because you created an empty model but 7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity 8 | // classes for your model, open the model in the designer, right-click on the designer surface, and 9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation 10 | // Item...'. -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/Model.Impl.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNet.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 8 | { 9 | public partial class User : IUser 10 | { 11 | Guid IUser.Id 12 | { 13 | get { return UserId; } 14 | } 15 | } 16 | 17 | public partial class UserRole : IRole 18 | { 19 | Guid IRole.Id 20 | { 21 | get { return RoleId; } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/Model.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/Model.edmx.diagram: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/User.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class User 16 | { 17 | public User() 18 | { 19 | this.Claims = new HashSet(); 20 | this.Logins = new HashSet(); 21 | this.Roles = new HashSet(); 22 | } 23 | 24 | public System.Guid UserId { get; set; } 25 | public string UserName { get; set; } 26 | public string Email { get; set; } 27 | public bool EmailConfirmed { get; set; } 28 | public string PasswordHash { get; set; } 29 | public string SecurityStamp { get; set; } 30 | public string PhoneNumber { get; set; } 31 | public bool PhoneNumberConfirmed { get; set; } 32 | public bool TwoFactorEnabled { get; set; } 33 | public Nullable LockoutEndDateUtc { get; set; } 34 | public bool LockoutEnabled { get; set; } 35 | public int AccessFailedCount { get; set; } 36 | 37 | public virtual ICollection Claims { get; set; } 38 | public virtual ICollection Logins { get; set; } 39 | public virtual ICollection Roles { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/UserClaim.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class UserClaim 16 | { 17 | public System.Guid UserId { get; set; } 18 | public System.Guid ClaimID { get; set; } 19 | public string ClaimType { get; set; } 20 | public string ClaimValue { get; set; } 21 | 22 | public virtual User User { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/UserLogin.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class UserLogin 16 | { 17 | public System.Guid UserId { get; set; } 18 | public string LoginProvider { get; set; } 19 | public string ProviderKey { get; set; } 20 | 21 | public virtual User User { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Models/UserRole.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace XperiAndri.AspNet.Identity.EntityFramework.Models 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class UserRole 16 | { 17 | public UserRole() 18 | { 19 | this.Users = new HashSet(); 20 | } 21 | 22 | public System.Guid RoleId { get; set; } 23 | public string Name { get; set; } 24 | 25 | public virtual ICollection Users { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) XperiAndri, LLC. All rights reserved. See LICENSE.txt in the project root for license information. 2 | 3 | using System.Reflection; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EntityFramework")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("XperiAndri")] 13 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EntityFramework")] 14 | [assembly: AssemblyCopyright("Copyright © 2015 XperiAndri")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("d6f41fdb-1bf1-4ef1-a2eb-d54e6808fa9f")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace XperiAndri.AspNet.Identity.EntityFramework { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("XperiAndri.AspNet.Identity.EntityFramework.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Role {0} does not exist.. 65 | /// 66 | internal static string RoleNotFound { 67 | get { 68 | return ResourceManager.GetString("RoleNotFound", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Value cannot be null or empty.. 74 | /// 75 | internal static string ValueCannotBeNullOrEmpty { 76 | get { 77 | return ResourceManager.GetString("ValueCannotBeNullOrEmpty", resourceCulture); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/XperiAndri.AspNet.Identity.EntityFramework/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/XperiAndri.AspNet.Identity.EntityFramework.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) XperiAndri, LLC. All rights reserved. See LICENSE.txt in the project root for license information. 2 | 3 | using System.Reflection; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("XperiAndri.AspNet.Identity.EntityFramework.Tests")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("XperiAndri")] 13 | [assembly: AssemblyProduct("XperiAndri.AspNet.Identity.EntityFramework.Tests")] 14 | [assembly: AssemblyCopyright("Copyright © 2014 XperiAndri")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("dbc81833-d8bb-4ce8-b6c5-2ef6b5bb7f55")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | -------------------------------------------------------------------------------- /test/XperiAndri.AspNet.Identity.EntityFramework.Tests/XperiAndri.AspNet.Identity.EntityFramework.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {EDB5DE31-B19F-4105-8150-093CADEEB206} 7 | Library 8 | Properties 9 | XperiAndri.AspNet.Identity.Model.Tests 10 | XperiAndri.AspNet.Identity.Model.Tests 11 | v4.5.1 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll 40 | True 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {311feca9-f3ce-49a7-b085-b9dafa25ca0a} 62 | XperiAndri.AspNet.Identity.EntityFramework 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | False 73 | 74 | 75 | False 76 | 77 | 78 | False 79 | 80 | 81 | False 82 | 83 | 84 | 85 | 86 | 87 | 88 | 95 | -------------------------------------------------------------------------------- /test/XperiAndri.AspNet.Identity.EntityFramework.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------