asp.net MVC combines EDMX data Model validation __.net

Source: Internet
Author: User

This is one of the issues that I have recently solved, the ado.net entity Validation model added in MVC3. Of course this is a customer request, do not like this thing, each mapping database will generate a lot of code. However, the function is still relatively powerful, do not write data access code themselves. is a quick development to select a framework. Ok. Get to the point.


asp.net MVC combines EDMX data Model validation in two different ways:

First type:

is to modify the database's table structure to a null type ...   Then add an attribute above the attribute ... Direct validation can be ...

The exception is thrown when debugging, but it does not affect the project when it is published or running normally.



Had



Disadvantages:

1. Inability to perform very complex validation

2. To modify the structure type of the database

3. It's not easy to throw an exception when you debug.

Advantages:

1. More convenient, do not need to add redundant validation entity classes





The second type:

is to add a validation entity class at the time of validation. The rest is configured according to the characteristics of MVC, and then add mappings in class to map the types of your entity classes







I now test is these two methods, another ordinary model or directly add features are good. Do you have any questions you can communicate with ~~~~~~~~~~~~




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.