【问题标题】:How get SimpleMembership in MVC4 project to create custom UserProfile fields for existing database?如何在 MVC4 项目中获取 SimpleMembership 以为现有数据库创建自定义 UserProfile 字段?
【发布时间】:2013-03-19 03:18:45
【问题描述】:

我想让 SimpleMembership 提供程序在我现有的数据库中创建必要的表,包括自定义 UserProfile 表。问题是 SimpleMembershipInitializer 忽略了 CreateDatabase 方法或现有数据库,而 WebSecurity.InitializeDatabaseConnection 方法只创建了标准的 UserProfile 而没有我的自定义字段。

那么有什么方法可以让 SimpleMembershipInitializer 类在调用 WebSecurity.InitializeDatabaseConnection 以创建 SimpleMembership 提供程序所需的其他表之前将我的增强型 UserProfile 表添加到现有数据库中?现有的数据库首先用作模型,而不是代码。

【问题讨论】:

  • 你能发布你的 UserProfile 模型吗?如果 WebSecurity.InitializeDatabaseConnection 指向您的 UserProfile 表,那么您需要通过匿名对象将附加字段作为列/值对传递给 AccountController 中的 WebSecurity.CreateUserAndAccount 方法。

标签: entity-framework simplemembership


【解决方案1】:

在这里你会找到一个可以帮助你的教程, http://blog.spontaneouspublicity.com/including-asp-net-simple-membership-tables-as-part-of-your-entity-framework-model

你是先用代码吗?

【讨论】:

    猜你喜欢
    • 2012-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-07
    • 2014-02-06
    相关资源
    最近更新 更多