Base solution for your next web application
Open Closed

VS Template for new module? #2663


User avatar
0
bilalhaidar created

Hello,

If I want to organize my code in solution folders, where every solution folder has its own .Core, .Application, .EntityFramework.

Do you have a VS template to create a new module?

For instance, if I want my ModuleX to define some permissions, am I supposed to only added them in the main .Core project, or I can add them in the .Core of my ModuleX?

Reason, why I am asking for this is, I want to keep the framework code untouched and do my work in some other modules, so that I might have it easier to upgrade the framework code when a new release is out.

Thanks Bilal


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We don't have it at the moment but it is in our future plans.

  • User Avatar
    0
    bilalhaidar created

    Good to know.

    Any guides now on how to do that manually? Steps involved, references, etc.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Actually we don't have such a document, you have to do it manually by yourself. If you have any problems on the way, we can help you for specific problems.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    So, let me share with you steps:

    1. Create a new Solution Folder
    2. Create .Core, .Application and .EntityFramework class libraries
    3. Add needed class references, etc.
    4. Make the main Web Module depend on the custom .Application module?

    Is that it?

    Thanks

  • User Avatar
    0
    JeffMH created

    We do this in ours. It would take me a bit of time to document everything but this is very doable. In every project, I have a Module and a CustomDtoMapper class at the root. I took this from the framework's Application project. I like this so I use that same thing when I create my own project.

    1. In our Core project, we implemented our own Authorization provider (inherit from AuthorizationProvider just like theirs does) and in that projects Module, just call Configuration.Authorization.Providers.Add<MyAuthorizationProvider>();

    2. Make your Modules dependent on their module. As an example, in your Core project's Module, add a DependsOn for the frameworks Core module. Make sense?

    3. You will need to wire up the API parsing inside the WebAPI project. This is the big one that converts the AppServices to WebAPI methods. Search for DynamicApiControllerBuilder and you can see where they registered their Application Module. You will need to add a DependsOn your Application module here also.

      Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
               .ForAll&lt;IApplicationService&gt;(typeof(MyApplicationModule).Assembly, "app")
               .Build();
      
    4. Not sure you can get away with Multiple EF projects. Just keep that as one. Unless you had separate DbContext classes, I don't see how this would help a ton. I move all their Migrations into a sub folder in the Migrations folder to keep their migrations separate from mine. This helps to keep things separate on the EF side. Other than that, never had any issues with this approach.

    We also have our own SettingsProvider. We register that in the Web Module. As you go, it's pretty easy to figure out what they did to copy. I will say that we can keep from changing the framework stuff about 90% of the time. Sometimes it's impossible to avoid changing the framework code.

    Hope that helps a little. If you just start to create your own Application and Core project, you will figure it out pretty quick.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @JeffMH, you are great :)

  • User Avatar
    0
    bilalhaidar created

    Thanks @JeffMH. i will follow the steps and see how it goes.