none
Entity Framework Code First - Relationship with a View in the Database RRS feed

  • Question

  • Is it possible to create a relationship in entity framework code first with a database view but without adding data to the view? 

    I have the following scenario:

    In my model i have the following entities:

    public class UserProfile
        {
            public int UserProfileId { get; set; }
            public string Name { get; set; }
            public List<Pharmacy> Pharmacies { get; set; }
        }

        public class Pharmacy
        {
            public int PharmacyId { get; set; }
            public string Title { get; set; }
            public List<UserProfile> UserProfiles { get; set; }
        }

    The entity Pharmacy is a View in the database. I want to create a many-to-many relationship with that view but i don't want that the EF generates this entity as a table in my database. Is this possible?

    Thank you so much for every help in advance.

    Greets

    ronny54

    Monday, March 18, 2013 7:47 PM

All replies