Questions tagged as 'code-first'

0
answers

How to improve the loading of related entities using LinqKit?

Hi, I'm using LinqKit to stack "Expression Predicates", so I need to do a "foreach" to do the entities Load related and this is being very costly for application because to load 1000 records is taking in average 4 minutes. Is there any way to...
asked by 28.05.2015 / 05:49
1
answer

Code first migrations does not work

I made a separate layer called 'Date' public class Context : DbContext { public Context() : base("EscolaContext") { } public DbSet<Escola> Escolas { get; set; } public DbSet<Turma> Turmas { get; set; } publ...
asked by 23.02.2017 / 18:11
1
answer

How to change the column name of a table using the Add-Migration Code First command Asp.Net MVC

I have a table already created and I want to change the name of the column without it being deleted, since it already has a lot of information. I did the procedure to rename the Street to Address property in the class and after I ran the Add...
asked by 15.10.2017 / 14:41
2
answers

Entity Framework - When editing, fails in "db.Entry (category) .State = EntityState.Modified;"

I have a "Category" Entity, which contains id, name, created, and updated. I'm using Code First. This is my template: public class Category { public int CategoryId { get; set; } public string Name { get; set; } public DateTime C...
asked by 31.03.2017 / 17:01
2
answers

InvalidOperationException when using the Set method of the DatabaseContext

When you use the DbContext.Set () method, the following exception is raised:    The entity type is not part of the model for the current   context If I create a DbSet directly in the DatabaseContext, it works. But my current need is to cr...
asked by 25.07.2014 / 21:13
1
answer

datetime vs dateime2, which one is the best?

I'm implementing a new project, using EF6 CodeFirst , EF6 creates my Sql-Server database, with date columns like datetime . What would be the difference between datetime and datetime2 , and which one is most likely to be used?     
asked by 06.04.2018 / 15:08
1
answer

Dependencies with EntityFramework C #

My question is how to use the state class include for parents because the city class has no parent connection. How can I accomplish this sql loading dependencies? private void FrmCidade_Load(object sender, EventArgs e) { var registros = Co...
asked by 15.09.2017 / 17:26
1
answer

Json Web Api with error

I have a REST service in WEB API, I use 2 related entities (person and user) 1 = 1 relationships, the post to insert this ok, retrieve the data, searching for the id of the user too, but when I try to search all the records I get the following e...
asked by 14.06.2017 / 12:46
1
answer

How to change and maintain mapping of classes and properties using ADO.net

When using a database I have tables and columns with names like: - tb_user usu_id usu_name usu_data_nasc - tb_product pro_id pro_name pro_desc_resumida pro_desc_completa When you use ADO.NET Entity Data Model - &g...
asked by 07.06.2017 / 13:40
1
answer

Error saving entity framework

I have a very basic problem, but I must be short of coffee to understand what is happening. I have an entity like this: public class Client : BaseEntity<Client> { [Required] public string CorporateName { get; set; } // V...
asked by 20.04.2017 / 00:29