相关疑难解决方法(0)

使用SimpleMembership和EF模型优先

可以SimpleMembership与使用EF模型的第一?当我尝试它时,我打电话时"无法找到所请求的.NET Framework数据提供程序"WebSecurity.InitializeDatabaseConnection.

换句话说:WebSecurity.InitializeDatabaseConnection当连接字符串使用System.Data.EntityClient提供者时,我无法接受调用(就像使用模型优先范例时那样).

要重新解决此问题,请创建一个MVC 4应用程序,并使用您在实体设计器中创建的模型优先用户类替换代码优先的 UserProfile实体类(使用MVC 4模板免费获得):

  1. VS 2012中创建一个MVC 4应用程序并添加一个新的空白实体数据模型.
  2. 添加一个名为User模型的新实体,其中包含字段Id, UserName, and FullName.因此,此时,User数据实体被映射到Users表,并通过使用System.Data.EntityClient提供程序的时髦连接字符串进行访问.
  3. 验证EF是否可以访问User实体.一种简单的方法是基于User表及其关联的DbContext构建一个Users控制器.
  4. 编辑该AccountModels.cs文件以删除UserProfile该类及其关联的UsersContext类.使用对新User类及其关联类的引用替换对(现在缺少的)UserProfileUsersContext类的引用DbContext.
  5. Move the call to InitializeDatabaseConnection from the InitializeSimpleMembershipAttribute filter class to the Application_Start method in Global.asax.cs. While you're at it, modify the …

entity-framework simplemembership

24
推荐指数
3
解决办法
2万
查看次数

标签 统计

entity-framework ×1

simplemembership ×1