我的应用程序我使用的是ASP身份 [英] I my application I am used ASP identity

查看:97
本文介绍了我的应用程序我使用的是ASP身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i

 create asp.net identity application in this application i used custom class Name Called ApplicationRole and That class is inherited with IdentityRole 

public class ApplicationRole:IdentityRole
{
       public ApplicationRole():base()  { }
       public bool IsSuperAdmin { get; set; }
}
 and then i used this class on the <pre lang="C#">OnModelCreating Method</pre>

protected override void OnModelCreating(DbModelBuilder modelBuilder)
       {
           base.OnModelCreating(modelBuilder);
           modelBuilder.Entity&lt;ApplicationUser&gt;().ToTable(&quot;tblUser&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;UserID&quot;);
           modelBuilder.Entity&lt;ApplicationRole&gt;().ToTable(&quot;tblRoles&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;RoleID&quot;);
           modelBuilder.Entity&lt;IdentityUserRole&gt;().ToTable(&quot;tblUserRole&quot;).Property(x =&gt; x.RoleId).HasColumnName(&quot;RoleID&quot;);
           modelBuilder.Entity&lt;IdentityUserRole&gt;().ToTable(&quot;tblUserRole&quot;).Property(x =&gt; x.UserId).HasColumnName(&quot;UserID&quot;);
           modelBuilder.Entity&lt;IdentityUserClaim&gt;().ToTable(&quot;tblUserClaim&quot;).Property(x =&gt; x.Id).HasColumnName(&quot;ClaimID&quot;);
           modelBuilder.Entity&lt;IdentityUserLogin&gt;().ToTable(&quot;tblUserLogin&quot;);


       }
after this i used Add-migrations and then update-DataBase
now i opened sql Server it will create aspnetRole table extra





我尝试过:



公共类ApplicationRole:IdentityRole

{

public ApplicationRole():base(){}

public虚拟Office OfficeID {get;组; }

public bool IsSuperAdmin {get;组; }

}



公共类办公室

{

[Key]

public long OfficeID {get;组; }

公共字符串OfficeName {get;组; }

公共虚拟ICollection< applicationuser>用户{get;组; }

public virtual ICollection< applicationrole>角色{get;组; }

}







protected override void OnModelCreating(DbModelBuilder modelBuilder)

{



base.OnModelCreating(modelBuilder);

modelBuilder.Entity< ApplicationUser>()。ToTable (用户)。属性(x => x.Id).HasColumnName(UserID);

modelBuilder.Entity< IdentityUserRole>()。ToTable(UserRole);

modelBuilder.Entity< IdentityUserClaim>()。ToTable(UserClaims)。Property(x => x.Id).HasColumnName(ClaimID);

modelBuilder。实体< IdentityUserLogin>()。ToTable(UserLogin);

modelBuilder.Entity< ApplicationRole>()。ToTable(Roles)。Property(x => x.Id).HasColumnName (RoleID);



}



What I have tried:

public class ApplicationRole : IdentityRole
{
public ApplicationRole() : base() { }
public virtual Office OfficeID { get; set; }
public bool IsSuperAdmin { get; set; }
}

public class Office
{
[Key]
public long OfficeID { get; set; }
public string OfficeName { get; set; }
public virtual ICollection<applicationuser> User { get; set; }
public virtual ICollection<applicationrole> Role { get; set; }
}



protected override void OnModelCreating(DbModelBuilder modelBuilder)
{

base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("User").Property(x => x.Id).HasColumnName("UserID");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims").Property(x => x.Id).HasColumnName("ClaimID");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin");
modelBuilder.Entity<ApplicationRole>().ToTable("Roles").Property(x => x.Id).HasColumnName("RoleID");

}

推荐答案

好吧,我冒险在这里挨打我的回答。



最好的据我所知,ASP Identity是Microsoft编写的一个固定解决方案,为您提供存储身份信息的安全方式。它包括App_Start中所需的所有组件,用于对参数,模型和控制器进行编程,其中视图在配置后可以100%工作。它有一切都在引擎盖下。



当然你可以调整它,但为了调整或改变它你必须逆向工程它的工作方式,所以你可以了解如何改变它。话虽如此,我试图在7个月前做同样的事情并花了大约2天的时间来处理它。



我终于意识到其中的关键领域我想改变编译在DLL中的ASP身份,没有源代码,我无法完成我的修改。我确实超越了你的问题所反映的观点。



所以我结束了这个想法并从头开始创建一个根据我的需求量身定制的新身份计划。我使用了作为项目基础的逆向工程知识,然后从我的项目中删除了ASP身份。
Well I'll risk taking a beating here for my anwser.

To the best of my knowledge, the ASP Identity is a canned solution written by Microsoft to provide you with a secure way to store identity information. It includes all the components needed in App_Start to program the parameters, models and controllers with views that works 100% after configuration. It has everything under the hood.

Sure you can tweak it, but in order to tweak or change it you will have to reverse engineer how it works, so you can understand how to change it. With that being said, I tried to do the same thing about 7 months ago and spent about 2 days working on it.

I finally realized that the key areas in which I wanted to change were compiled in the DLL for ASP Identity, and without the source, I could not finish my modifications. I did make it past your point that your question reflects.

So I ended scrubbing the idea and started from scratch creating a new identity program that was tailored to my needs. I used the reverse engineering knowledge that I gained as the foundation of my project, then stripped out the ASP Identity from my project.


这篇关于我的应用程序我使用的是ASP身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆