【发布时间】:2013-02-05 12:47:20
【问题描述】:
我正在尝试首先使用模式 (EF5) 构建数据库,并添加简单的成员资格。
在“绘制”我的架构后,我添加了用户配置文件表(UserId&UserName),删除了
过滤器:InitializeSimpleMembershipAttribute,去掉这一切..
//public class UsersContext : DbContext
//{
// public UsersContext()
// : base("DefaultConnection")
// {
// }
// public DbSet<UserProfile> UserProfiles { get; set; }
//}
//[Table("UserProfile")]
//public class UserProfile
//{
// [Key]
// [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
// public int UserId { get; set; }
// public string UserName { get; set; }
//}
在生成的类中(首先按模式)我尝试手动添加
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
到我的 UserProfile 类
我也在我的 AppStart 中注册了:
WebSecurity.InitializeDatabaseConnection("Model1Container", "UserProfile",
"UserId", "UserName", autoCreateTables: true);
但在调试时我收到此错误:
Unable to find the requested .Net Framework Data Provider. It may not be installed
WebSecurity.InitializeDatabaseConnection("Model1Container", "UserProfile",
有什么好的做法吗?
是否可以先使用模式?
【问题讨论】:
标签: entity-framework asp.net-mvc-4 asp.net-membership simplemembership