CreateUserAndAccount方法 - SimpleMembership Provider

时间:2016-10-25 14:17:54

标签: mysql asp.net simplemembership

我有两个问题:

  1. 为什么我会得到那个例外?我想在我的用户表(它有6列:Name,Role,Email,Group,Id,SoftwareVersion)和Membership表中创建一行。主键是Id-SoftwareVersion对。代码:
  2. code

    怎么了?

    1. 是否可以通过更改ID添加更多行(使用CreateUserAndAccount)?对?示例:当DB中具有相同名称的条目已存在时,尝试添加“Administrator”作为UserName的行(但我记得主键是Id-SoftwareVersion对)。
    2. 我的用户类:

      public partial class User
      {
          public User()
          {
              this.dfcs = new HashSet<Dfc>();
              this.fids = new HashSet<Fid>();
              this.histroyDeliverRequests = new HashSet<Histroyrequest>();
              this.histroyProposalRequests1 = new HashSet<Histroyrequest>();
          }
      
          public string Name { get; set; }
          public string Role { get; set; }
          public string Email { get; set; }
          public string Group { get; set; }
          public int Id { get; set; }
          public short SoftwareVersion { get; set; }
      
          public virtual ICollection<Dfc> dfcs { get; set; }
          public virtual ICollection<Fid> fids { get; set; }
          public virtual ICollection<Histroyrequest> histroyDeliverRequests { get; set; }
          public virtual ICollection<Histroyrequest> histroyProposalRequests1 { get; set; }
          public virtual Software Software { get; set; }
      }
      

1 个答案:

答案 0 :(得分:0)

我想你在插入用户表时应该省略Id,因为我认为在插入新记录时Id会自动递增?