├── .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 | 
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 | 
18 |
19 | 
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 | 
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