Questions tagged as 'code-first'

3
answers

What is the difference between Data Annotations and Fluent API?

What's the difference between Data Annotations and Fluent API? Are there any restrictions between one or the other? Improve performance or are they just two ways to do the same?     
asked by 28.11.2016 / 20:07
2
answers

EF 6, Mapping with Fluent Api in classes with inheritance

I am training the class mapping for the Entity Framework using the Fluent API and I have some questions. The first is this: Mapping a foreign key with attributes would look like this: public int EmpresaId {get; set;} [ForeignKey("EmpresaI...
asked by 19.03.2014 / 15:56
1
answer

How do I set default properties for a variable that start with a specific text?

Is there any way to set the properties of a variable by default to the initials of variables? Something like public string obsUsuario { get; set; } , all of which start with obs default to the IsOptional property, (or / and oth...
asked by 25.11.2016 / 17:11
1
answer

How to create a foreign key in a table where data already exists, in the EntityFramework with Code-First?

I have a system already in production from which the customer has requested a modification. Modification is the creation of an EMPLOYEE table that will relate to the DRIVE table, creating a 1: N relationship (One Employee, multiple DRIVES)....
asked by 10.04.2015 / 22:37
2
answers

CRUD with images, working with HttpPostedFileBase and byte []

We are using the EntityFramework with CodeFirst and DataBase PostgreSQL. There are some tables that should save images, and POCO classes are referenced as byte array. Up to this point everything is quiet. I can get the images with HttpPostedF...
asked by 25.08.2017 / 05:17
2
answers

Code First with Complex Types, when doing Scaffolding Complex Types properties are not found in the views

I'm following the presentation of Sergey Barskiy in link , where he demonstrates the approach of Entity FrameWork with Code First. I loved it, but I had a problem. In the presentation, it demonstrates that I can use Complex Types for the...
asked by 04.02.2014 / 15:30
1
answer

Create unique attribute beyond the Primary Key in code-first

I am creating a Logradouro table where the CEP field is not the primary key, but must be unique. How do I do this using code-first in Entity 6.0 ? To create primary key I use the HasKey method: ToTable("Logradouros...
asked by 16.06.2016 / 21:27
1
answer

AspNet MVC database first or code first

I have an AspNet MVC 5 project in which I will use Owin and identity, I needed to customize identity (attributes and relations) to meet my needs, however I already have all the "ready" bank tables ), in these already existing tables I'll create...
asked by 11.08.2016 / 14:53
1
answer

Is it possible to use composite key for Entity Framework with Model First?

I have the modeling down and I need to map composite keys as the embedded id of hibernate, but in the entity framework using the model first, is it possible?     
asked by 30.10.2015 / 22:48
1
answer

Why are relations in the Entity Framework code first pointed to with ICollectionT?

Why relationships in the Entity Framework code first are pointed to with ICollection? What is the best instantiation (?) For the property in common cases? List Is the use of the virtual keyword only to enable lazy loading on the property?     
asked by 06.01.2015 / 21:51