I have a problem with EF 4.1
Here are my entities and context:
public class PasmISOContext : DbContext
{
public DbSet<Avatar> Avatars { get; set; }
public DbSet<User> Users { get; set; }
}
namespace PasmISO.Domain
{
public class User
{
[Key]
public string Login { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public Avatar Avatar { get; set; }
}
}
namespace PasmISO.Domain
{
public class Avatar
{
[Key]
public int Id { get; set; }
[Required]
public Uri Link { get; set; }
}
}
at mvc controller I have
PasmISOContext db=new PasmISOContext();
if (db.Avatars.Count()==0)
{
db.Avatars.Add(new Avatar() { Link = new Uri("http://www.google.com/somelinktojpg") });
}
When I run my code, I get exception:
One or more validation errors were detected during model generation:
System.Data.Edm.EdmEntityType: : EntityType 'Uri' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Uris� is based on type �Uri� that has no keys defined.
Any ideas on how to get around this?