Questions tagged as 'code-first'

1
answer

Code First versus Database First?

I'm used to creating projects in ASP.NET MVC with Entity Framework Database First. From a modeling, the database and the system are created. However, I see a lot of programmers prefer Code First, where the database depends on the system. W...
asked by 10.11.2014 / 21:51
2
answers

Relationship N for N and One for N with CodeFirst Data Annotations

How can I make the N to N and N to N relationships using Data Annotations? For example: A sales move has a user, and a user can have multiple moves. This same sales movement has several products, and each product can be in several movem...
asked by 21.06.2014 / 03:35
2
answers

Code First and Calculated Fields

I have a class Pedido , which has a calculated field, which is the value of the request, consisting of the sum of the items minus the discount. public class Pedido { public ICollection<PedidoItem> Itens { get; set; } publi...
asked by 25.11.2015 / 14:23
1
answer

Mapping Code First with Data Annotations

I'm creating a project using DataAnnotations mapping with Code First (similar to Hibernate ), without using FluentAPI . It turns out that by implementing this process, some exceptions are being raised and I believe it is due t...
asked by 21.06.2014 / 03:10
1
answer

Help with configuring DbContext with EntityFramework using good practices

I have my application layered with Class Library and my layer with Entity Framework , where I set DbContext , it's Repository . My class inherited from DbContext: public class Context : DbContext { private stati...
asked by 18.03.2014 / 01:36
1
answer

Auto Relationship in EF

I'm having the following problem when creating two auto relationships. When you run the Update-Database the following error message appears:    Unable to determine the main end of an association between the   types 'Autorelação.Franquia'...
asked by 28.07.2016 / 15:49
1
answer

Execute insert in Migrations Entity Framework

I'm developing an ASP.NET MVC project with Entity Framework Code First. I've mapped the bank and managed the first Migrations, my question is: can I run a insert shortly after a table is created? Example: CreateTable( "dbo.P...
asked by 06.01.2016 / 23:08
1
answer

I can not get a provider for Oracle with Code First

I'm doing the following: Model dou Add folder > New Item follows images ThenIselectADO.NetEntity,giveitaname,andADD SelectCodeFirstandgiveNext Wellatthisstep,Iselect,andseefromtheimagethatIdonothavetheOracleClientoptionandIalreadyaddediti...
asked by 05.11.2015 / 13:14
2
answers

How do I prevent a property from being mapped to an entity in the Entity Framework?

I need to insert a property in the template class, but when I enter the code first, it says that the table already exists and changes have been made. My code: public class Data { [Key] public int Id { get; set; }...
asked by 04.03.2014 / 15:37
2
answers

What is the reason for using DbMigration in CodeFirst?

What is the purpose of using DbMigration when developing a project using CodeFirst? Is using it a good practice, or is it something that does not cause major impacts on the implementation and / or maintenance of the system?     
asked by 22.06.2014 / 00:37