Questions tagged as 'entity-framework-core'

2
answers

How can I access the database directly from my model class in an ASP.NET Core project?

In ASP.NET Core Mvc I get access to DbContext on the Controller through the _context property represented by my MvcNotaContext class see: private readonly MvcNotaContext _context; This way I can search the database in the cont...
asked by 20.11.2017 / 16:59
1
answer

Use ILogger with .Net Core 2

I am studying .Net Core 2 and I have a question. I am trying to get error in my Repository layer and only saw example in Controller. Any specific reason for this? Here are my codes: appsettings.json { "ConnectionStrings": { "Defaul...
asked by 27.05.2018 / 02:02
1
answer

How to get the Schema of a Model in a DbContext made in the Entity Framework Core

Hello, I'm starting to work with EFCore and I'm doing an Override in the SaveChanges() method so that whenever there is a manipulation of the database I can log it. My problem is that I'm working with Schemas in my bank and I do not know h...
asked by 12.06.2018 / 13:48
1
answer

Map Object Object in Entity Core

I have the class public class Email { public string Endereco { get; } public string NomeExibicao{ get; } } I'm trying to map to EF Core using the following code builder.Property(e => e.Email.Endereco) .HasColu...
asked by 20.03.2018 / 16:45
1
answer

Migration with possible data loss

When generating an update of db that results in possible loss of data efcore shows alert:    An operation was scaffolded that may result in the loss of data.   Please review the migration for accuracy. (In this specific cas...
asked by 11.01.2017 / 02:43
1
answer

LINQ to SQL - Exception when giving sum () in a query that contains another subquery using LINQ

private decimal GetBankAccountCashierTotal() { var company = _context.Company.FirstOrDefault(); return _context.PersonBankAgencyAccount .Where(p => p.PersonID.Equals(company.PersonID)) .Wh...
asked by 01.12.2016 / 16:30
0
answers

Use 2 models in a View, but separate them in the form submission

I'm getting the following error:    'AddEmployeeViewModel' does not contain a definition for 'OfficeEmployee' and in the extension method 'OfficeEmployee' accepting the first argument of type 'AddEmployeeViewModel' could be found > Inside...
asked by 01.11.2018 / 18:18
0
answers

"Could not parse expression '...: The given arguments did not match the expected arguments" [closed]

I am using the CompiledQueries feature of the framewok core 2.0 entity but even though it does not syntax error, when the program is running, I get this exception:    Could not parse expression 'value   (Microsoft.EntityFrameworkCore.Query.In...
asked by 08.09.2018 / 09:26
1
answer

MIgrations error loading System.Configuration.ConfigurationManager - MIgrations

I have a WPF project that contains a app.config containing the consection string and tb I have a Date layer of type ClassLibrary .dot net Standard on which to create the Migrations folder. When I give an "Add-Migration Start" the syste...
asked by 11.01.2018 / 00:37
1
answer

Migrations HasMaxLength x HasColumnType

I'm creating a simple test table with EF Core e SQlite The first test in which modelbuilder creates a migration (shown just below) protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.En...
asked by 17.09.2016 / 04:52