DCSIMG
DbContext - Shimmy on .NET

Browse by Tags

All Tags » DbContext (RSS)

Entity-Framework Code First Designer with Database Initialization in few simple steps! by Shimmy

I find it very frustrating that I cannot use the entity model designer to generate code-first DbContext & entities that retains all the aspects of code-first including database initialization. Here are a set of instructions that can easily help you to achieve true code-first using the EDM designer, and allowing initialization of database (database initialization is not supported in model-first, it only allows generation of database scripts that has to be generated on the server). This is very...

UniqueAttribute that validates a unique field against its fellow rows in the database (inherits DataAnnotations.ValidationAttribute) by Shimmy

UPDATE: Jan 30 2012 : Added check that entity is not itself (i.e. when user attempts to save the same entity). UPDATE: Feb 26 2012 : Added support for inherited entities, where the validated property is on the sub-class of the inheritance hierarchy. Here is a ValidationAttribute subclass that will allow you to validate that a column doesn't have duplicates. It's intended to be used with EF 4.1 DbContext , or with the EF4's ObjectContext . namespace System . ComponentModel . DataAnnotations...
Powered by Community Server (Commercial Edition), by Telligent Systems