Questions tagged as 'code-first'

1
answer

Self-relationship in EF6

I need to do a self-relationship in one of the entities, how do I reference the entity itself for both child records and the parent record? public class Comentario { public int IdComentario { get; set; } public int? IdComentarioPai { g...
asked by 10.04.2014 / 15:10
1
answer

Error when running Updad-Database command

When I run the Update-Database command in the Package Manager Console, I get the following error:    Value can not be null.   Parameter name: entitySet I have only one model in the project for now public class Project { [Key]...
asked by 27.10.2017 / 15:01
1
answer

Error in 1 to 1 relationship declaration in EF with code-first and attributes!

I have the following classes where I want to do a 1 to 1 relationship: User: [Table("Usuario")] public class Usuario { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [Required]...
asked by 01.07.2014 / 16:38
1
answer

Exception DbUpdateException

I'm trying to study EF with Code First. I'm getting this exception at SaveChanges() An unhandled exception of type System.Data.Entity.Infrastructure. DbUpdateException occurred in EntityFramework.dll Additional information: An erro...
asked by 02.09.2015 / 03:26
1
answer

Code First Migrations MySQL - Specify the '-Verbose' flag to view the SQL statements being applied to the target database

I'm creating a Web application in C # and for the sake of the hosting server, the database is in MySql. So I installed MySql.Data.Entity, EF6, I activated Migrations, added the class Migrations, but at the time of giving Update-database -Verb...
asked by 03.07.2015 / 07:42
1
answer

How to disable Migrations from a project with EF6?

Hello I have a class library with templates using Code First and I enabled Migrations with the "enable-migrations" command in PMC to test and it works very well. Since I'm at the beginning of the model definitions, I'd rather leave it for aft...
asked by 21.04.2014 / 20:29
1
answer

How to simplify the type declaration with Entity Frameowrk?

I have some tables with several fields of type datetime, and for all of them I need to create a validation in OnModelCreating () for this type, that is, I need to set .HasColumnType("datetime"); , my doubts are; Is there a more practical...
asked by 24.11.2016 / 13:59
1
answer

Doubt when setting entity relationship

In one scenario, I have an address registration entity: public class Endereco { [Key] public int EnderecoId { get; set; } public string TipoLogradouro { get; set; } public string Logradouro { get; set; }...
asked by 04.12.2015 / 20:54
1
answer

Performance on queries with string filter vs foreign key

I'm working on a Asp.Net MVC 5 project that uses code first and all entities have a property named UserId of type string . When I make queries filtering by a certain user ( Asp.Net Identity ) I do so: string cu...
asked by 20.08.2015 / 19:18
1
answer

Version of MySql.Data.Entity compatible with MySql 5.6

What are the versions of: MySql.Data MySql.Data.Entity EF Compatible with version 5.6 of MySql?     
asked by 24.07.2015 / 06:02