Using Entity Framework Model First with Asp.Net Membership Provider

放肆的年华 提交于 2019-12-13 04:28:03

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/17622932/using-entity-framework-model-first-with-asp-net-membership-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!