DEV Community


Discussion on: Which would be better for career: Laravel or .NET Core?

dgvai profile image
Jalal Uddin Author

My day 2 of learning .NET Core,
*. I have been creating Models like a normal class and defining its props, then adding the repository and it's interface class, that's ok until you go into multiple model and you see code duplication.
*. I wanted to know, that, all models do have some default props like ID, created_at, updated_at and some CRUD ops, like create, find, update, delete, etc, and those I have to implement here (in my beginner case) manually by creating classes. Isn't there any NuGet Packages that does handle this ORM so it saves production time?

Thread Thread
theonlybeardedbeast profile image
TheOnlyBeardedBeast • Edited

crate a base class which has all these properties you need everywhere, then all the new models should extend this base class. You can create a base generic repository using generics. But basically the entity framework contains all these operations if you succesfully created a databasecontext, you can easily do all the things.

I created a snippet for you with these things:

You just need to update the generic repository so it should be based on the BaseEntity class, and then you can add additional logic to the update methods (updating updatedAt property) or you can add a findById method