EF5 Migrations throwing error on simplemembership seed
Error:
No mapping exists from object type eTrail.Models.Global.Address to a known
managed provider native type.
The code that is throwing the error:
if (!WebSecurity.UserExists("me"))
        {
            WebSecurity.CreateUserAndAccount(
                "me",
                "password", new
                {
                    FirstName = "Firstname",
                    LastName = "Lastname",
                    Email = "me@me.com",
                    Address = new Address
                    {
                        Street = "123 Stree",
                        Street2 = "",
                        City = "CityVille",
                        State = "UT",
                        Zip = "99999",
                        Country = "USA",
                        PhoneCell = "111.111.1111"
                    },
                    CreatedDate = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    ImageName = ""
                });
        }
My User.cs Model:
    public class User : IAuditInfo
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int UserId { get; set; }
    public string UserName { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    [DataType(DataType.EmailAddress)]
    public string Email { get; set; }
    public Address UserAddress { get; set; }
    public DateTime CreatedDate { get; set; }
    public DateTime ModifiedDate { get; set; }
    public ICollection<Role> Roles { get; set; }
    public string ImageName { get; set; }
    public User()
    {
        UserAddress = new Address();
        Roles = new List<Role>();
    }
}
The Address Model:
public class Address
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }
    public string Street { get; set; }
    public string Street2 { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zip { get; set; }
    public string Country { get; set; }
    public string PhoneHome { get; set; }
    public string PhoneCell { get; set; }
    public string PhoneOther { get; set; }
    public string FaxNumber { get; set; }
}
Any idea why I am getting this error? Both Model classes are in my
DbContext class as DbSet and DbSet.
No comments:
Post a Comment