0

Is there any advantage in creating a separated namespace for each of my POCO classes in a Code First Entity Framework project ?

this:

namespace Domain.POCO.Table1
{
    class Table1 { }
}

namespace Domain.POCO.Table2
{
    class Table2 { }
}

instead of this:

namespace Domain.POCO
{
   class Table1 { }
}

namespace Domain.POCO
{
    class Table2 { }
}

in the first case one can say the code is "better organized" but this option creates a lot of "using" statements everywhere else on the code.

Is there any benefit related to assembly loading or other ?

1
  • Why would you want to use Domain.POCO.Table1.Table1? Also, those are generally called entities not POCOs Feb 14, 2018 at 11:25

2 Answers 2

0

Is there any advantage in creating a separated namespace for each of my POCO classes

No, and there is a general guideline against naming a class and a namespace the same. In contrast to the filename, that should be equal to the class name.

So I would suggest

// MyEntity1.cs
namespace MyProject.Domain.Entities
{
   public class MyEntity1 { }
}
0

No, there's no advantage to having one-class-per-namespace. You can group related objects in the same namespace if it makes sense to you, but having a namespace for each class is just going to make the code more verbose for now reason.

Not the answer you're looking for? Browse other questions tagged or ask your own question.