Dreamcatcher
Dreamcatcher

Reputation: 828

EF does not create model from database

I've three table as Screenshot1. I would like to create entity data model with generate from database. However MDSClinicOperation table does not mapped from Entity Framework (Screenshot2). If there is an any bugs, or did I some mistake? (I use Mssql 2012, entity framework 6.1, netframework 4.5)

Screenshot1

Screenshot1

Screenshot2

Screenshot2

Upvotes: 0

Views: 72

Answers (2)

Neil Smith
Neil Smith

Reputation: 2565

No mistake. There's no need for the bridge table in your entities because each has a collection of the other. It's a valid many-to-many relationship. For example, if you have departments with many employees where employees can belong to many departments can be represented as:

public class Department
{
    public int Id { get; set; }
    ...
    public ICollection<Employee> Employees { get; set; }
}

public class Employee
{
    public int Id { get; set; }
    ...
    public ICollection<Department> Departments { get; set; }
}

Even though I don't have a 'bridge' entity between the two, a single employee can have many departments and a single department can have many employees thus a many-to-many.

Upvotes: 2

Kenci
Kenci

Reputation: 4882

I believe that cross-reference tables do not get created as classes in the Entity Framework. You should, for instance, be able to access all the operations a clinic has through the "MDSOperation" property in the MDSClinic object.

Upvotes: 0

Related Questions