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:
- The EDMX file name when adding ADO.NET entity data model to the project. I put ‘MyEF.edmx’.
- When saving the connection string into the config file. I put ‘MyEntities’.
- After selecting some tables to include in my model, there’s a textbox to input model namespace. I put ‘MyModel’.
- Property ‘custom tool namespace’ of the MyEF.edmx file. I put ‘TheEF’.
- Property ‘custom tool namespace’ of the MyEF.Context.tt file. I put ‘TheContext’.
- Property ‘custom tool namespace’ of the MyEF.tt file. I put ‘TheModel’.
Opening MyEF.edmx with ADO.NET entity data model designer, looking at the properties of MyModel, there are:
- entity container name, filled with ‘MyEntities’. So the connection string name goes here.
- namespace, filled with ‘MyModel’. This is coming from the table selection textbox.
Putting something into the edmx custom tool namespace doesn’t seem to do anything. I got this conclusion because when I grep the entire source code folders, I found it only in a vbproj file.
Putting ‘TheModel’ into MyEF.tt custom tool namespace produces error from MyEF.Context.vb saying type ‘MyTable’ (this is the name of my database table) is not defined.
Can someone explain the purpose of each label?
If I want to put all the classes generated by this one edmx (DbContext, models, etc.) into one namespace, ‘MyEF’, what should I put in each of those places?