none
As of VS2019 I need to add the assembly name when referencing methods RRS feed

  • Question

  • In my Visual Basic Web application, that was originally created in VS2017, I needed to update my EDMX file because some stored procedures were added.

    As of then my code does not recognize the methods generated in the model. Only when I prefix it with the assembly name, it works.

    My project is called QA_ScrapReport. This is the assembly name and root namespace.

    Previously this code would work just fine:

    Public Shared Function GetUserFunctions() As List(Of sp_qasr_GetUserFunctions_Result)
    Dim functionsList As New List(Of sp_qasr_GetUserFunctions_Result)
    Using dc As New HENUS_ProductionEntities
    Dim q = From s In dc.sp_qasr_GetUserFunctions Select s
    functionsList = q.ToList
    End Using
    Return functionsList
    End Function

    As of VS2019, I need to prefix all the methods generated in the model with the assembly name like below:

    Public Shared Function GetUserFunctions() As List(Of QA_ScrapReport.sp_qasr_GetUserFunctions_Result)
    Dim functionsList As New List(Of QA_ScrapReport.sp_qasr_GetUserFunctions_Result)
    Using dc As New QA_ScrapReport.HENUS_ProductionEntities
    Dim q = From s In dc.sp_qasr_GetUserFunctions Select s
    functionsList = q.ToList
    End Using
    Return functionsList
    End Function

    This only happens when the ADO.NET model is updated. When the model is not touched, the code still works!

    Wednesday, May 22, 2019 3:20 PM

All replies

  • You should move away from using the EDMX and EF database first, which has been depreciated, if you ever move to EF Core. You can use EF code first and run stored procedures. But on the other hand, if all you are running is sprocs, then you defeat the purpose of using an ORM such as EF. 
    • Edited by DA924x Wednesday, May 22, 2019 9:38 PM
    Wednesday, May 22, 2019 9:37 PM
  • Hi BGT,

    To try to reproduce the issue, I create a project via VS2017 and open it in VS2019. But there is no need to add namespace as a prefix. To handle it efficiently, could you please provide more useful information? Such as a simple project.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 23, 2019 6:38 AM
    Moderator
  • Hi Kyle,

    I uploaded a very simple solution here: https://1drv.ms/f/s!An4xtVR9jVD7prljunLBi7za6DLSmA

    I just created the EDMX file and added a class to access its methods in VS2019. It produces the same result.

    Thursday, May 23, 2019 6:50 AM
  • Hi BGT,

    I noticed the full name of "WebApplication1" is "WebApplication1.WebApplication1".

    But the namespace of "sp_qasr_GetUserFunctions_Result" is "WebApplication1". So you need to remove the namespace "WebApplication1" of "sp_qasr_GetUserFunctions_Result" and "HENUS_ProductionEntities", or import "WebApplication1" into the project.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 23, 2019 7:54 AM
    Moderator
  • That is just the question!

    I did not need to do that before.

    In my original project I have an EDMX connected to another database. No need to import namespaces, it just works.

    As soon as I edit one EDMX, I need to add the namespace.

    I uploaded that project to the onedrive folder so you can see.

    Thursday, May 23, 2019 8:39 AM