Reputation: 1
I have applied some validation with data annotations but somehow I am missing something in the code. Here is my Model class in Model Folder: Model Class IMAGE-01
and here is my Validation Class (cs) in ViewModel Folder
When we run the project , validation not working.
Upvotes: 0
Views: 187
Reputation: 8204
Create Tbl_Users
class in a separate file and change the namespace like this
namespace InventoryLogin.Models {
[MetadataType(typeof(InventoryLogin.ViewModel.LoginValidation))]
public partial class Tbl_Users{}
}
Upvotes: 0
Reputation: 162
The namespace of your partial classes for Tbl_Users are in different namespaces (InventoryLogin.Models and InventoryLogin.ViewModel).
These partial classes need to be in the same namespace for the data validation rules to be applied correctly to the class.
Upvotes: 1