Questions tagged as 'entity-framework'

4
answers

How to handle this NullReferenceException

I do not understand the reason for receiving a NullReferenceException , in this beautiful code: pessoaJuridica.InscricaoEstadual = viewmodel.PessoaJuridica.InscricaoEstadual; What am I doing wrong? Follow whole code public async...
asked by 29.06.2017 / 21:53
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 format 'DateTime?' in dd / mm / yyyy format using Linq?

I have query below, but when I try to format the field Data_nascimento and Data_exclusao with .ToString("dd/MM/yyyy") it returns me a runtime error.    The 'System.String ToString (System.String)' method has no con...
asked by 11.11.2016 / 13:24
1
answer

Creating ForeignKey

Well, in my project I decided to use some Foreign Keys. And after you end up getting this error:    {"The INSERT statement conflicted with the FOREIGN KEY constraint \" FK_dbo.Setors_dbo.Areas_setorAreas \ ". The conflict occurred in database...
asked by 08.06.2016 / 18:43
3
answers

Entity Framework [ForeignKey]

Reading a tutorial on the entity framework, I came across a rather strange example for me. This example is about the DataAnnotation [ForeignKey] public class Student { public Student() { } public int StudentID { get; s...
asked by 05.05.2016 / 17:38
1
answer

Entity Framework DDD Generic Repository

How to do JOIN via lambda in the generic repository. I'm following the DDD architecture model. Example: public class BaseRepository<T> : IRepositoryBase<T> where T : class { private IDbContext _context; private read...
asked by 15.11.2014 / 01:41
1
answer

Entity FrameWork Objects

I'm having a question with Entity Framework I have a situation in which I want to implement a structure in the database of a chart of accounts, for example: the current active account ID 1.1 is the parent of the account box 1.1.1, is my busin...
asked by 12.04.2016 / 21:25
1
answer

How to save the same object using the .net MVC entityFramework in the database?

I need to update to a table in the database using entityFramework, because when I update a value of a field and I send save, it gives error. Please someone have a way to solve this ?? grateful usuarioVM.ContatoUsuarios = ContatoUsuari...
asked by 13.01.2015 / 19:08
1
answer

Select in Entity Framework is not working

I am doing a query using LINQ, very simple query I am using the following method. public void verificaAcesso( string usuario, string senha) { using (DbBancoContext banco = new DbBancoContext()) { var resultadoConsulta = from u...
asked by 10.10.2014 / 18:52
1
answer

Popular a List with database data accessed by EntityFramework

How popular is my List in C #, with the data stored in the database accessed through EntityFramework? Current code: public static IEnumerable<Contato> GetAll() { return new List<Contato> { //DAqui pa frente nao se...
asked by 06.01.2015 / 14:10