I have a model as follows:
public class User : System.Web.Security.MembershipUser
{
public int UserId { get; set; }
public string SomeProperty { get; set; }
}
When my database is generated I want the Entity Framework to ignore MembershipUser and only generate a table named User with the two properties from the User class. I’ve tried the following to no avail.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Ignore<System.Web.Security.MembershipUser>();
}
NotMappedAttributeattribute is your friend:I’m not sure if code first processes the metadata automatically by itself, try the above, and if it doesn’t work, attach the metadata manually (i.e. uncomment the commented lines).
Update
I do like the above solution better, but if it’s too verbose for you, use the
StructuralTypeConfiguration<TStructuralType>.Ignore<TProperty> Methodmethod: