entity-framework-core

Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux

穿精又带淫゛_ 提交于 2020-02-28 07:50:25
问题 I've tried adding <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" /> However 2.2.0 is the latest version available at this time, which doesn't match the error. The error is still the same after rebuilding the app. project.csproj: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>linux-x64</RuntimeIdentifier> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore

Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux

蓝咒 提交于 2020-02-28 07:48:30
问题 I've tried adding <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" /> However 2.2.0 is the latest version available at this time, which doesn't match the error. The error is still the same after rebuilding the app. project.csproj: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>linux-x64</RuntimeIdentifier> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore

Add-Migration while using database in separate Docker container throws an error

情到浓时终转凉″ 提交于 2020-02-25 06:30:08
问题 I've created dockerized ASP.net Core app with auto-generated identity setup (so I've already had by default entity framework configuration). I've created SQL Server as separate container, here is my docker-compose.yml : version: '3.4' services: blazorapp1: image: blazorapp1 build: context: . dockerfile: Dockerfile depends_on: - db db: image: "mcr.microsoft.com/mssql/server" environment: SA_PASSWORD: "[SOMEPASSWORD]" ACCEPT_EULA: "Y" I've tested database configuration: as Visual Studio

Invalid SQL Server Connection String on Linux Entity Framework Core

ぃ、小莉子 提交于 2020-02-24 14:08:37
问题 I'm using Linux more specifically Xubuntu. I have installed SQL Server Express on my machine. I'm currently in the making of a web app and my connection does not seem working or I don't understand everything quite right? The output I get is : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

List returned by Entity Framework is null [duplicate]

蓝咒 提交于 2020-02-24 10:20:51
问题 This question already has an answer here : EF Core returns null relations until direct access (1 answer) Closed 18 days ago . I have these two classes, Field and Field2 with a one-to-many relationship. When I am trying to get Field , the list returns with records with the id and the name, which is correct. But trying to read the Field2 from Field is always empty. What can be the cause? I have tried everything. I can see the FK in the database etc. public class Field : IEntityBase { public int

List returned by Entity Framework is null [duplicate]

試著忘記壹切 提交于 2020-02-24 10:15:15
问题 This question already has an answer here : EF Core returns null relations until direct access (1 answer) Closed 18 days ago . I have these two classes, Field and Field2 with a one-to-many relationship. When I am trying to get Field , the list returns with records with the id and the name, which is correct. But trying to read the Field2 from Field is always empty. What can be the cause? I have tried everything. I can see the FK in the database etc. public class Field : IEntityBase { public int

Sum of hours (HH:MM) in Linq

微笑、不失礼 提交于 2020-02-24 06:13:34
问题 I am having "TimeClocked" in my database table in the format HH.mm and I want to sum all the "TimeClocked" using LINQ. I have tried this aggregate function. var data = _projectDbContext .Tasks .Where(x => x.Project.CompanyId == companyId && x.Status == true) .Select(e => TimeSpan.Parse(e.TimeClocked)) .Aggregate(TimeSpan.FromMinutes(0), (total, next) => total + next) .ToString(); I am using EF Core 3.0.0 . It's showing error like this. Processing of the LINQ expression 'Aggregate<TimeSpan,

Sum of hours (HH:MM) in Linq

点点圈 提交于 2020-02-24 06:12:31
问题 I am having "TimeClocked" in my database table in the format HH.mm and I want to sum all the "TimeClocked" using LINQ. I have tried this aggregate function. var data = _projectDbContext .Tasks .Where(x => x.Project.CompanyId == companyId && x.Status == true) .Select(e => TimeSpan.Parse(e.TimeClocked)) .Aggregate(TimeSpan.FromMinutes(0), (total, next) => total + next) .ToString(); I am using EF Core 3.0.0 . It's showing error like this. Processing of the LINQ expression 'Aggregate<TimeSpan,

Linq WHERE EF.Functions.Like - Why direct properties work and reflection does not?

丶灬走出姿态 提交于 2020-02-24 05:29:02
问题 I try to perform a simple LIKE action on the database site, while having query building services based on generic types. I found out while debugging however, that performing EF.Functions.Like() with reflection does not work as expected: The LINQ expression 'where __Functions_0.Like([c].GetType().GetProperty("FirstName").GetValue([c], null).ToString(), "%Test%")' could not be translated and will be evaluated locally. . The code that makes the difference That works : var query = _context.Set

Include with FromSqlRaw and stored procedure in EF Core 3.1

百般思念 提交于 2020-02-23 10:40:30
问题 So here's the deal - I am currently using EF Core 3.1 and let's say I have an entity: public class Entity { public int Id { get; set; } public int AnotherEntityId { get; set; } public virtual AnotherEntity AnotherEntity { get; set; } } When I access the DbSet<Entity> Entities normal way, I include AnotherEntity like: _context.Entities.Include(e => e.AnotherEntity) and this works. Why wouldn't it, right? Then I go with: _context.Entities.FromSqlRaw("SELECT * FROM Entities").Include(e => e