EF Entity 'required' property
Hey there, I'm currently creating a project where I'm using EF as ORM.
Take the following as an example entity:
https://pastebin.com/bGZnXYvw
Entity is a base class that houses our 'Id' property with a generic type - This way I can either choose int, Guid, ...
The reason I use 'required string' is so that I
As we're already limiting our model properties as required, would EF recognize this? Making the IsRequired() methods on the corresponding properties irrelevant?
Or should we still limit this, as this might be more expressive?
I think the IsRequired() on the foreign key could be left out, as we're not using int? for this property, but correct me if I'm wrong...
Are there any more improvements I could make to this?
EDIT:
I'm building the models from an existing database, once our old applications are finally converted we'd use code-first migrations in order to manage the database.
Take the following as an example entity:
https://pastebin.com/bGZnXYvw
Entity is a base class that houses our 'Id' property with a generic type - This way I can either choose int, Guid, ...
The reason I use 'required string' is so that I
- Don't get compiler warnings about needing to declare a value when exiting the constructor
- Because the column in the Database is not-null anyway
As we're already limiting our model properties as required, would EF recognize this? Making the IsRequired() methods on the corresponding properties irrelevant?
Or should we still limit this, as this might be more expressive?
I think the IsRequired() on the foreign key could be left out, as we're not using int? for this property, but correct me if I'm wrong...
Are there any more improvements I could make to this?
EDIT:
I'm building the models from an existing database, once our old applications are finally converted we'd use code-first migrations in order to manage the database.

Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.