Table not mapped to Entity Framework Data Model

℡╲_俬逩灬. 提交于 2019-12-05 17:59:37

Well, your working now with objects, no more sql.

And with EF, many to many relationships don't need a special "entity", but a particular "relation".

In User class, you'll have a list of Roles, and in Roles class, a User list. Which represent perfectly a simple many to many relationship.

If you had at least onother property in your relation table (a "RelationName" string, for - stupid - example), then it would exist in the EF model...

EDIT : Not sure of what you need : that's just the "object" way. Think of the way you would create these classes if you weren't working with a Database : you would do a List of the other in each part of relation. But Sql can't do that (you can't have a "list" in a database), so Sql needs a relation table. But EF is an ORM, so object, not sql.

EDIT 2 :

The way you would create your relation in Code First, but it's quite explicit http://blogs.msdn.com/b/wriju/archive/2011/05/14/code-first-ef-4-1-building-many-to-many-relationship.aspx

For more answers, just google "Entity framework many to many" sould do the trick

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