Problem with Entity Declarations and objects RRS feed

  • Question

  • Hello !

    I'm using Vb.net 2013 , Entity Framewrok 5.0 (ObjectContext model) , Sql Server 2008R2 (Database bame MyDB , has one table MyTable)

    I Created model.EDMX  , Entity name is MyDBEntities1

    Now I want to declare a variable as entity :

    Dim e as MyDBEntities1

    But I get an error to MyDBEntities1 . As solutions I get "Import WindowsApplication1.MyDBModel"

    I have some previous projects , and the declaration is like I wrote.

    What's the problem with this project ?

    Thank you ! 

    Thursday, February 27, 2014 4:32 PM


  • Hello,

    >> What's the problem with this project ?

    It is by designed in VB projects.

    For Visual Basic projects, if no value has been set for the Custom Tool Namespace property and the project has an empty namespace, the namespace of the generated code will be the conceptual model namespace as specified in the .edmx file. For more information, see Determining the Default Namespace. If you specify the custom tool namespace, the Visual Studio compiler will prepend the project's root namespace to the name you specified. Even though the types are defined in the specified namespace, when you declare the types, you must import defaultnamespace.specifiednamespace. For example, if your project's root namespace is ProjectDefaultNamespace and in the Custom Tool Namespace property you specified TestNamespace, when you declare the types that are defined in the TestNamespace namespace, you must use: Import ProjectDefaultNamespace.TestNamespace.

    For details, see it here and find “Determining the Namespace of Generated Code” section.

    So “Import WindowsApplication1.MyDBModel” is the correct solution.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Thursday, March 6, 2014 9:01 AM
    Friday, February 28, 2014 4:35 AM