Questions tagged as 'entity-framework'

1
answer

Random order with Entity Framework

I would like to translate the following SQL statement to a lambda expression: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in the OrderBy that will be accepted? var pessoa = contexto.tbPessoa.OrderBy(???).FirstOrDe...
asked by 04.01.2017 / 14:34
1
answer

Modeling with Code First so you can change databases

If I generate my database for MySQL using the concept of Code First can I change it to SQL Server in the future? Do you need to change the classes or just the config and provider ?     
asked by 17.04.2017 / 15:27
2
answers

Fluent API relationship questions for EF 5

I have two classes: User > Contains your PK (ID). UsuarioP > Contains user ID (FK). Class User.cs public Usuario() { this.UsuariosP = new List<UsuarioP>(); } public int Id { get; set; } (...) public virtual ICo...
asked by 28.09.2015 / 15:21
1
answer

How to do a Lambda sort with a List property?

I believe this has already been asked before. I researched but did not find it. I'm having trouble with this query, specifically on the ThenBy command that tries to sort the sub-list of objects. I know it's in it because when you comme...
asked by 21.10.2014 / 18:23
1
answer

Time difference in Linq

I'm using Entity Framework, and I have a condition that has not worked very well: .Where(x => ((DateTime.Now - (x.DataInicio.Value == null ? DateTime.Now : x.DataInicio.Value)).TotalMinutes) < x.Item.MinutosMaximo) Types : x.D...
asked by 27.10.2015 / 12:45
1
answer

How to Configure Mapping Entity Framework 1: N Using Inheritance

I have two classes: Pessoa and Usuario . The Usuario class inherits the properties and methods of the Pessoa class. I'm using the Entity Framework and I believe you're doing the wrong mapping. So the problem is happ...
asked by 13.02.2017 / 15:57
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
1
answer

Entity Framework Update Database

When I run the command Update-Database I get the following error    Could not load file or assembly 'Microsoft.Build.Framework,   Version = 15.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a 'or   one of its dependencies....
asked by 14.12.2017 / 12:03
2
answers

Keep records of synchronized tables between two different databases

We are performing a system migration, where some restructurings will be made in the current bank in a new bank. Basically I will have two banks BancoVelho and BancoNovo , having to keep the two updated according to the mapping of th...
asked by 22.04.2016 / 21:22
1
answer

Add migration and make update at runtime EntityFramework

I'm developing an application and the need to add migration and run the update at runtime. I already have all the part that loads the modules: public class ClientContext : DbContext { protected override void OnModelCreating(DbModelBuil...
asked by 10.06.2015 / 03:31