Questions tagged as 'dataannotations'

2
answers

Inheritance in the Entity Framework

I'm now reading about cross-domain inheritance in EF. I came across this example: public abstract class BillingDetail { public int BillingDetailId { get; set; } public string Owner { get; set; } public string Number { get; set; } }...
asked by 28.05.2016 / 17:54
1
answer

Error creating custom validation in ASPNET MVC (Client Side)

I have a problem creating a custom validation using dataanotations by aspnet mvc. My Model: public class Usuario { public string Nome { get; set; } [Idade(18)] public string Senha { get; set; } }...
asked by 08.10.2018 / 16:40
1
answer

How can I break lines of an ErrorMessage from a Data Annotation?

I have this property and Data Annotations for it: [Required(ErrorMessage = "Campo orbgiatório.")] [RegularExpression("^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$", ErrorMessage = "The password must contain: \n * Pelo menos 8 caracteres; \n *Pelo me...
asked by 04.10.2018 / 15:02
0
answers

Compound key mapping entity framework

Good afternoon, How do I map compound key in my entities, in case the entity calls document and its PK is by property ID and WEBID, and it does FK with the User as I would in that case? Document public class Documento : IAggregate...
asked by 06.09.2018 / 00:48
0
answers

How to Scaffolding an Unmapped Property (NotMapped)

I'm working with a MVC 5 project with Entity Framework , where through Code First I created a template class that has a field which does not exist in the database, in the case of the ConfirmPassword field. This field should appear in a...
asked by 07.04.2018 / 23:14
0
answers

How do I dynamically load Calendar generated by DataAnnotation in Edit with existing data?

My class with the declaration of the "DateNascimento" field, which when filled should load the datepicker generated by DataAnnotation when called in view edit. public class Cliente { [Key] public int ClienteId { ge...
asked by 27.01.2018 / 21:10
0
answers

Entity Framework (Database first) - Include DataAnnotations

I saw in an MS link that it is possible to create a partial and a Metadata class to include DataAnnotations in properties created by the Entity Framework (database first). Well, I did as the example, but the application has an error:    The m...
asked by 28.12.2017 / 14:47
3
answers

DataAnotation Attribute for Currency

I would like to format with DataAnnotation currency but default en in the model: [Column("cur_mensalidade")] [DataType(DataType.Currency)] [DisplayFormat(DataFormatString = "{0:C0}")] public decimal? Mensalidade { get; set; } but does no...
asked by 03.05.2016 / 14:34
1
answer

DataAnnotation Validations Do Not Work on Properties with NotMapped Attribute in EF6

I upgraded the Entity Framework version from 5 to 6 in my project, and the Data Repository Context.SaveChanges stopped working in only a few cases. I found that using DataAnnotation in properties of my template that contained the [NotMapped]...
asked by 11.06.2015 / 19:11