Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Namespaces in Entity Framework

I am trying to change the Namespace used by Entity Framework Generator of classes.

When I click the designer of my Entity, Model.edmx, I can see somewhere where I can change the namespace:

Namespace

under ConceptualEntityModel properties. Changed that namespace, but nothing happened. Didn't work. So, I read some help from this link:

http://weblogs.asp.net/zeeshanhirani/struggling-through-namespace-in-entity-framework

says that I have to change the property: Custom Tool Namespace

That's nice, when I click property of .edmx in console application, there property is there. But when I am using the same thing in a Web Application, the property is not there. There is only a property file called Web File Properties that simply has 3 properties:

  • Custom Tool
  • File Name
  • Full Path

What am I missing here?

like image 274
TatiOverflow Avatar asked Nov 11 '14 02:11

TatiOverflow


People also ask

What is model namespace in Entity Framework?

A namespace in the Entity Data Model (EDM) is an abstract container for entity types, complex types, and associations.

Can you rename a namespace?

Second this, you can't rename your namespace but Velero makes it pretty easy to back and restore to a new namespace.


3 Answers

rainerh is right:

I tried to set *.edmx Custom Tool Namespace property - this did not help.
I tried to set *.Context.tt property - this did not help too.
But when I set Custom Tool Namespace property of *.tt file (right-click on the file -> Properties) - namespace was set automatically for all the classes genereated before.

like image 190
Taras Kozubski Avatar answered Oct 06 '22 22:10

Taras Kozubski


Open your edmx file first then press F4 or click on the properties window. Under the Schema section, there is a property called Namespace which you can modify.

like image 5
Scotty Avatar answered Oct 06 '22 23:10

Scotty


In my case, I just simply created a folder within the project, moved the .edmx file to the folder I created(using the solution explorer), and everything just automatically changed namespaces.

like image 4
Ray Lionfang Avatar answered Oct 06 '22 22:10

Ray Lionfang