Questions tagged as 'code-first'

1
answer

One-To-Many relationship with explicit foreign key name

I'm performing a simple one-to-many mapping via Fluent API specifying which column is used in the mapping, but EF "ignores" the configuration and continues using the default . Mappings: public AtividadeMap() {...
asked by 16.07.2015 / 20:33
1
answer

Can the automatically generated .mdf database in App_Data be used in production?

Can the database automatically generated within the App_Data folder in projects Asp.Net MVC and Web-Api be used in production or is it a test-only basis?     
asked by 15.07.2014 / 13:45
1
answer

How to set a field of type string as nullable in Code First?

I have the field descrPapel of type string and would like this field to be created as nullable , that is, accept null when doing some insert / update entity type. using System; using System.Collections.Generic; usi...
asked by 25.11.2016 / 15:49
1
answer

Dependency Injection - Error: InvalidOperationException: Unable to resolve service for type

Friends, once more I come to you for help. When trying to call an Action from my Controller I'm getting the problem described below:    An unhandled exception occurred while processing the request.   InvalidOperationException: Unable to re...
asked by 07.10.2018 / 17:00
1
answer

EF 6 Code First: Decimal field gives error when trying to save

Hello, good morning. I have a class that has a decimal field where I save the price. So far so good. When it is displayed in the / Edit / of the page, it is also beauty. But that's the problem: 1 - The MVC (which I am using 4 with EF 6) it di...
asked by 04.07.2015 / 10:30
1
answer

Code First One to Many May be null

My scenery: public class AlunoAvaliacao { public int AlunoAvaliacaoID { get; set; } public DateTime Inicio { get; set; } public DateTime? Fim { get; set; } public virtual int AvaliacaoID { get; set; }...
asked by 06.12.2014 / 17:01
1
answer

How to publish .mdf database in Azure SQL Dabases?

I have solution with a Asp.Net MVC 5 project and I'm using Code First and Migrations to update the .mdf database automatically generated in the App_Data folder. How do I put this .mdf in Azure and can u...
asked by 15.09.2014 / 20:56
1
answer

How do you model 1x0..1 relations (optional one-to-one) in the Entity Framework Code First?

When an Entity MAY have one (and only one) instance of another Entity, but the second Entity MUST have the first, how is Entity Modeling done?     
asked by 31.01.2014 / 19:50
2
answers

When placing a class in DbSet using Migrations

I have the following classes: public DbSet<Request> Requests { get; set; } public DbSet<Answer> Answers { get; set; } being that they have a one-to-many relationship. When I want a class to be added to my EntityFramework migra...
asked by 08.06.2018 / 13:55
1
answer

Insert into 2 tables Entity framwork - 1 to 1

I have two entities generated by the code-first wizard: Person [Table("pessoa")] public partial class pessoa { public pessoa() { pessoa_endereco = new HashSet<pessoa_endereco>(); }...
asked by 10.06.2017 / 23:29