如何整合与实体框架会员表? Asp.net [英] How do I integrate Membership tables with Entity Framework? Asp.net

查看:119
本文介绍了如何整合与实体框架会员表? Asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有使用实体框架中的一个项目之前,所以我不知道从哪里开始。我有我使用正在使用ASP.Net成员资格提供程序时作为创建成员表。

I have never used Entity Framework in a project before so I am not sure where to begin. I have I am using the membership tables that are created when using ASP.Net membership provider as is.

我想创建一个包含用户的参考对象。例如:

I would like to create an object that contains a reference to a user. For example

public int Id {get;set;}
public User User{get;set} // Where User is some object relating to Membership provider User.
public string Application {get; set;}

我使用的是code第一种方法使用EF所以我想,让它产生基于此对象的表。那么,如何配置这使EF会认识到,我创建由asp.net成员资格管理用户的关系?什么类型,我应该在上面的例子到位用户的使用(什么是asp.net型)

I am using a code first approach to using EF so I would like to let it generate tables based on this object. So how do I configure this so that EF will recognize that I am creating a relationship to a user managed by asp.net Membership? What type should I use in the above example in place of 'User' (what is the asp.net type)

很抱歉,如果这是含糊不清。我基本上只需要EF如何与Asp.net成员资格提供架构集成了一个例子或解释。

Sorry if this is vague. I basically just need an example or explanation of how EF integrates with Asp.net membership provider schema.

谢谢!

推荐答案

如果你想有哪些链接您的会员表和申请表1 EF模型,可以使用aspnet_regsql添加ASP.NET成员表现有数据库.EXE程序。有些链接:

If you want to have one EF model which links your membership tables and application tables, you can add the ASP.NET Membership tables to your existing database using the aspnet_regsql.exe utility. Some links:

  • MSDN documentation
  • Tutorial on the ASP.NET website

如果你已经安装了会员表,可以生成匹配的会员架构的EF code类。我贴就怎么做,这里的详细解说:

Once you have the Membership tables installed, you can generate EF Code classes that match the membership schema. I posted a detailed walkthrough on how to do that here:

<一个href=\"http://weblogs.asp.net/jgalloway/archive/2011/02/24/generating-ef-$c$c-first-model-classes-from-an-existing-database.aspx\">Generating从现有的数据库 EF code首先模型类

Generating EF Code First model classes from an existing database

这篇关于如何整合与实体框架会员表? Asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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