Where to put Entity Framework Data Model in MVC application?

后端 未结 4 1127
囚心锁ツ
囚心锁ツ 2021-02-02 15:25

Lets consider default ASP.NET MVC application folder structure, so it\'s looks like this:

-App_data
-Content
-Controllers
    HomeController.cs
-Models
    Accou         


        
4条回答
  •  情深已故
    2021-02-02 16:10

    I would put the EF-model (aka physical model) always in its own assembly or in a "core" assembly outside of main MVC application. The same applies for your business-logic / domain-logic / domain-services / etc. Separate the non-web stuff from the MVC-Web-Application.

    This will help you re-use the core part of your app. For example when you need to expose it as a service, a command-line tool, migration-tool, etc.

    Because storing this in its own assembly is so easy and takes you a few minutes I highly recommend doing this for each and every tiny app too.

提交回复
热议问题