Entity Framework 5 namespaces

后端 未结 1 1430
深忆病人
深忆病人 2021-02-09 09:50

I want to add Entity Framework 5 database first into a class library in Visual Studio 2012 targeting .net framework 4.5. I am confused with all the labels I need to key in:

相关标签:
1条回答
  • 2021-02-09 10:21

    The various properties are used as follows:

    • EDMX file name --> Used for the EDMX file name
    • Connection string name --> Used for the connection string name in the config file, and also for the container name of the conceptual model (CSDL) part of the EDMX
    • Model namespace --> Used for the namespace of the conceptual model (CSDL) part of the EDMX, and also for the store model (SSDL) part with .Store appended
    • Custom tool namespace for the EDMX file --> I don't believe this is used for anything when using T4 generation of POCO entities. When using EF1-style built in code generation, setting this property will set the .NET namespace for all generated files.
    • Custom tool namespace for .Context.tt file --> The .NET namespace used in the source file for the context
    • Custom tool namespace for .tt file --> The .NET namespace used in the source files for the entities

    Note that if you set the .Context.tt and .tt custom namespaces to different things, then the context will be generated in a different namespace to the entity types and this won't compile out-of-the-box. You can update the .tt files if you want to use different namespaces here, but more often people just use the same namespace for both.

    Also note that you may need to choose "Run Custom Tool" from the context menu for each .tt file after changing the properties in order for the code to be re-generated.

    0 讨论(0)
提交回复
热议问题