entity-framework

Do Entity Framework async methods consume ThreadPool threads?

我与影子孤独终老i 提交于 2020-06-10 03:41:46
问题 I usually use many EF Core async methods in my web application like this: await db.Parents.FirstOrDefaultAsync(p => p.Id == id); As we know, initial number of threads in ThreadPool by default is limited to number of CPU logical cores. Also user requests are handled by threads in ThreadPool . Should I worry about handling user requests or performance issues due to many async calls in my application? 回答1: Should I worry about handling user requests or performance issues due to many async calls

Entity Framework: The context is being used in Code First mode with code that was generated from an EDMX file

∥☆過路亽.° 提交于 2020-06-10 02:26:07
问题 I am developing an WPF application with EF 6 database first approach, I am have 1 project in my solutions, if i run my project this error always appear. The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity

Entity Framework PowerShell script cannot be loaded by Visual Studio because its operation is blocked by software restriction policies

北慕城南 提交于 2020-06-08 08:09:10
问题 When I load Package Manager Console within Visual Studio 2017 v15.9.6 in a project that uses Entity Framework I receive the following error: \packages\EntityFramework.6.2.0\tools\init.ps1 cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy. At line:1 char:45 + ... rgs+=$_}; & 'C:\Bitbucket\project-path\packages\EntityFramework.6.2. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo :

C# - How to get the directory path of a .NET Standard Library project inside a WPF solution

徘徊边缘 提交于 2020-06-01 05:30:32
问题 I have a VS2019 solution that has a WPF project referencing a .NET Standard 2.0 project included in the same solution. I am using Entity Framework Core on the .NET Standard Library project where the DbContext class is created as follows. Because the MyDbContext.cs file is inside the Standard Library project, I was expecting AppDomain.CurrentDomain.BaseDirectory directory in the code below to be inside \bin\Debug\ of the Standard Library project where MySQLite.db should have been created . But

Entity Framework Core throws System.Data.SqlTypes.SqlNullValueException when loading entities from DbContext

天涯浪子 提交于 2020-06-01 05:10:22
问题 I have this MyEntity table in the database: The data inside MyEntity is the following: The EF Core entity is the following: public class MyEntity { public int Id { get; set; } public int MyInt { get; set; } } I am getting an exception: System.Data.SqlTypes.SqlNullValueException: 'Data is Null. This method or property cannot be called on Null values.' when trying to load the MyEntity from the DbContext : var myEntities = dbContext.Set<MyEntity>.ToList(); What am I doing wrong? 回答1: You are

Why this app is trying to connect to SQL Server instead of SQLite?

泄露秘密 提交于 2020-06-01 05:06:25
问题 Environment : VS2019 , .NET 4.8 , EF 6 , SQLite , WPF App (.NET Framework) I am following this Microsoft official tutorial to create a code-first app, called WPF_EF6 using SQLite. With the configuration shown below, I am getting an error about failing to connect to SQL Server. But as you can see in the App.config file below, there is no SQL Server is involved here? Question : what may I be missing here? And how can we resolve the issue? App compiles fine but throws this runtime error. I

Filtering On ThenInclude Three Nested Levels down

大憨熊 提交于 2020-05-30 03:49:27
问题 I am trying to filter three child levels down and find only child elements where PropertyMailingAddress.Status== True. It is still returning values which are False under PropertyMailingAddress.Status How do I convert filter three levels down and conduct nested filtering with ThenInclude? Class Structure is nested like this: Property PropertyParty Party PartyMailingAddress PropertyMailingAddress <--- Status should equal true (Any grandchild PropertyMailingAddress nodes with Status == False,

Inject ApplicationDbContext into Configure method in Startup

放肆的年华 提交于 2020-05-29 11:52:07
问题 I'm using EntityFrameworkCore 2.0.0-preview2-final and I would like to inject the ApplicationDbContext into Configure method in Startup class. Here's my code: public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ApplicationDbContext context) { // rest of my code } but when I run my app I'm getting an error message: System.InvalidOperationException: Cannot resolve scoped service 'ProjectName.Models.ApplicationDbContext' from root provider. Here

Entity Framework Code First Migration

China☆狼群 提交于 2020-05-29 07:46:06
问题 We are using Entity Framework code first migration technique for a while now. Everything works good however our Migrations folder has been growing big with numerous migration files because of changes we are making on entity schema. I was curious, is there a way we can update just one or specific number of files whenever there is change in entity so that our Migrations folder would look less messy. Also, i don't want to drop the table and recreate it since i will be loosing all the saved data.

Entity Framework Code First Migration

徘徊边缘 提交于 2020-05-29 07:46:00
问题 We are using Entity Framework code first migration technique for a while now. Everything works good however our Migrations folder has been growing big with numerous migration files because of changes we are making on entity schema. I was curious, is there a way we can update just one or specific number of files whenever there is change in entity so that our Migrations folder would look less messy. Also, i don't want to drop the table and recreate it since i will be loosing all the saved data.