使用实体框架模型先用Asp.Net成员资格提供 [英] Using Entity Framework Model First with Asp.Net Membership Provider

查看:201
本文介绍了使用实体框架模型先用Asp.Net成员资格提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用MVC4和实体框架模型第一位。
我想知道我应该如何在asp.net成员资格提供表与实体框架模型相关联。

我尝试添加成员提供表到我的EF数据库。但是,当我做从asp.net成员资格提供用户配置表,我的表的一个之间的关联,会自动创建另一个用户配置表,并没有什么保存在原来的用户配置表。

我应该不会让这两者之间有什么关联,只是连接表合力得到用户相关的信息?有一个变通?还是我做的完全错误的?

感谢您!


解决方案

  

我尝试添加成员提供表到我的EF数据库中。


您不需要添加/如果你使用的创建成员表<一个href=\"http://www.hanselman.com/blog/IntroducingSystemWebProvidersASPNETUniversalProvidersForSessionMembershipRolesAndUserProfileOnSQLCompactAndSQLAzure.aspx\"相对=nofollow> ASP.NET通用提供商。它使用实体框架code首先,它会自动创建所需的表格,如果没有找到表格。

在新通用提供者,你将看不到preFIX表aspnet_了。

关系

您可以使用用户表的用户ID作为在其中存储用户相关信息的其他表的主键。

在下面的例子中, XXX_Profile 是一个自定义表。它的主键是由成员提供的用户表用户ID。

I am currently using MVC4 and entity framework model first. I was wondering how I am supposed to associate the asp.net membership provider tables with entity framework models.

I tried adding membership provider tables into my EF database. But when I make association between UserProfile table from asp.net membership provider and one of my table, another UserProfile table is automatically created and nothing is stored in the original UserProfile table.

Am I supposed to not make any associations between these two and just join table together to get user related information? Is there a work around? Or am I doing it totally wrong?

Thank you!

解决方案

I tried adding membership provider tables into my EF database.

You do not need to add/create Membership tables if you use ASP.NET Universal Providers. It uses Entity Framework Code First, and it'll create required tables automatically if tables are not found.

In new Universal Provider, you won't see tables with prefix aspnet_ anymore.

Relationship

You can use the UserId of User table as primary key in other tables in which you store user related information.

In the following example, XXX_Profile is a custom table. Its primary key is UserId from membership provider's Users table.

这篇关于使用实体框架模型先用Asp.Net成员资格提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆