Monday, February 24, 2014

Data Validation in Entity Framework

Validating data is important to make sure bad data is not getting into the system causing unnecessary troubles. When developing applications using Entity Framework, you can use features in .NET and Entity Framework to ensure only valid data will flow through it. Here we'll see what features we can use with Entity Framework to do our job

Using Data-Annotations

Data-Annotations are attributes you can add to property or a class. Data-Annotations are not a feature comes with Entity Framework. It's a feature of MVC. You must add System.ComponentModel.DataAnnotations to use this. 


IValidatableObject

Its is an interface which can be applied to a class. 

ValidateEntity


DbUpdateException

Exception throws by Entity Framework when updating to the database gets fails

References



updated November 2014

0 comments:

Post a Comment

Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook