I have been learning asp.net mvc for a while now and I am coming to grips with using the entity framework,
I have the following Model
[Table("User")]
public partial class User
{
// [ConcurrencyCheck]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Key]
public int Id { get; set; }
[Required]
[Display(Name = "User Name")]
[Remote("IsUserNameAvailable", "User", ErrorMessage = "User name already Exists.")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[StringLength(150, MinimumLength = 6)]
[Display(Name = "Password")]
public string Password { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string Surname { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email")]
[Remote("IsEmailAvailable", "User", ErrorMessage = "Email Address Already Exists.")]
public string Email { get; set; }
}
This all works fine when I register a user. But my problem is that I tried Doing something like this for login
[Table("User")]
public partial class Login
{
// [ConcurrencyCheck]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Key]
public int Id { get; set; }
[Required]
[Display(Name = "User Name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[StringLength(150, MinimumLength = 6)]
[Display(Name = "Password")]
public string Password { get; set; }
}
The reason I wanted this was so that I can use a model that would not have to use the remote Attribute as I wouldn't be checking if the username exists
The error I get when I do this says that I cannot use separate entities for the same table. I am trying to get around not triggering the remote attribute for the login part.
Has anyone come across this?
Thanks,