I have 2 questions:
- Why am I getting that exception? I want to create a row in my User Table (it has 6 columns: Name, Role, Email, Group, Id, SoftwareVersion) and in the Membership table. The primary key is the pair Id-SoftwareVersion. The code:
What's wrong?
- Is it possible add more row (with CreateUserAndAccount) by changing the id? Right? Example: try to add a row with "Administrator" as UserName when an entry already exists in the DB with the same name (but I remember the primary key is the pair Id-SoftwareVersion).
My User class:
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; }
}
I am thinking you should omit the Id, when inserting into the User Table, as I would think that the Id would auto increment, when inserting a new record?