ErikEJ / EntityFramework6PowerTools

This is the codebase for Entity Framework 6 Power Tools Community Edition, and modern EF 6 providers for SQL Server and SQL Server Compact
Other
183 stars 27 forks source link

Generate views ends up with two views for each entity #53

Closed watfordgnf closed 5 years ago

watfordgnf commented 5 years ago

I'm not sure if this is a problem with the generate views utility, with our DbContext, or if not a problem at all, but it appears to generate two equivalent views for each entity (with slightly different names):

            if (extentName == "CodeFirstDatabase.User")
            {
                return GetView1();
            }
            // ...
            if (extentName == "OurDbContext.Users")
            {
                return GetView145();
            }
// ...
        private static DbMappingView GetView1()
        {
            return new DbMappingView(@"
    SELECT VALUE -- Constructing User
        [CodeFirstDatabaseSchema.User](T1.User_UserId, T1.User_UserName)
    FROM (
        SELECT 
            T.UserId AS User_UserId, 
            T.UserName AS User_UserName, 
            True AS _from0
        FROM OurDbContext.Users AS T
    ) AS T1");
        }
// ...
        private static DbMappingView GetView145()
        {
            return new DbMappingView(@"
    SELECT VALUE -- Constructing Users
        [Name.Space.User](T1.User_UserId, T1.User_UserName)
    FROM (
        SELECT 
            T.UserId AS User_UserId, 
            T.UserName AS User_UserName,  
            True AS _from0
        FROM CodeFirstDatabase.User AS T
    ) AS T1");
        }

This code first EF model has had numerous migrations over the past six or so years, so it would not surprise me if a vestige was hanging around.

watfordgnf commented 5 years ago

I believe this is internal to our usage of EF and not related to the generated views.