entity-framework-core

Access is denied debugging ASP.NET Core app referencing Sqlite running in IIS

旧城冷巷雨未停 提交于 2019-12-11 00:12:52
问题 The ASP.NET Core 2.2 project references Microsoft.EntityFrameworkCore.Sqlite (2.2.3) as a PackageReference . Debugging the app in IIS Express works fine, because of the elevated user process. Problem: Debugging the app in IIS throws an error Unable to load DLL 'e_sqlite3' or one of its dependencies: Access is denied How can I debug the app in IIS without laborious publishing steps? My analysis so far: while e_sqlite3.dll is found and loaded successfully in the folder %userprofile%\.nuget

GroupBy query and bit fields

假如想象 提交于 2019-12-11 00:04:35
问题 I am using entity framework core 2.1, I have a database context with an accessor for a model containing a boolean field represented as a non nullable bit field in an MS SQL database. I want to construct a query that evaluates in SQL efficiently that provides me a count of all rows in the table, and those with the bit column enabled. var groups = await this.context.Models .AsNoTracking() .GroupBy(i => 1) .Select(g => new ViewModel { Count = g.Count(), Revoked = g.Count(p => p.IsRevoked) })

Identity value generation can only be used with signed integer properties after upgrade to EF Core 1.1

不羁的心 提交于 2019-12-11 00:04:27
问题 When I updated "Microsoft.EntityFrameworkCore.Tools.DotNet" to version "1.1.0-preview4" , entity framework has stopped to generate migrations. Error: dotnet : System.ArgumentException: Identity value generation cannot be used for the property 'UID' on entity type 'SomeEntity' because the property type is 'Guid'. Identity value generation can only be used with signed integer properties. 回答1: Solution is get rid of attribute [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key] //

Azure Functions 1.0.7 giving Could not load file or assembly error with EF Core 2

柔情痞子 提交于 2019-12-10 21:55:15
问题 I'm trying to move some functionality to Azure Functions. Created a project for EF Core 2 code, and referenced it to the Azure Functions project. Added the EF Core+SQLServer nugget packages to the Azure Functions project. When the function attempts to execute, this is the errors in the screen. I can see that the Microsoft.EntityFrameworkCore assembly is in the same directory as our azure functions dll. Can anyone shed some light on why it's not finding it and how to fix this? [1/3/2018 6:49

Using ExecuteSqlCommand and SavesChanges within same transaction with EntityFramework Core

Deadly 提交于 2019-12-10 21:27:40
问题 I am chasing an issue with MySql / EF Core where I randomly have an exception thrown saying Nested transactions are not supported . This exception does not occur when my system is only used by one user. But when I run my tests in parallel or when I have multiple users, the exception occurs. I looked at all the code and their is nothing that could create nested transactions. The only piece of codes that scares me so far is something like the following: using (var transaction = _context

IBM.EntityFrameworkCore - DbContext.OnConfiguring and DbContext.OnModelCreating aren't called

最后都变了- 提交于 2019-12-10 21:05:28
问题 As soon as I've solved one issue with IBM.EntityFrameworkCore, another one has arose. Everything is soooo hard and painful with DB2 and their .NET team... The problem: I have several EntityFrameworkCore - based projects in the same VS solution, for example MyDb2EfModel , MyMsSqlEfModel , and MyNpgsqlEfModel . (It's kind of a complex data-integration scenario.) On top of that I have a CLI project which references all the three and performs actual data ops. When the CLI project references only

EF Core lock the database during migration

偶尔善良 提交于 2019-12-10 20:57:49
问题 Is it possible lock the database from any other connections when running the migrations through Database.Migrate() ? We have multiple service instances running the same code (on AWS Lambda), and do the migrations on startup. Now we have to manually make sure that only one instance is running when we want to apply some migrations, otherwise they can both try to do it and break things bad. Is there a database level solution to this? ef-core 2.1 回答1: Not really sure if this is what you are

The string argument 'migrationId' cannot be empty

雨燕双飞 提交于 2019-12-10 20:33:07
问题 Apologies in advance if this has already been answered but I've honestly dug deep and could not find anything relating to this error. In a nutshell, I am unable to make any updates to my database using code first within my ASP.NET Core 1.1.2 project. It's throwing an exception because it's missing an argument which I'm guessing is not to do with PMC. Error message when using 'Update-Database': Text for cross checking Google ;-) System.ArgumentException: The string argument 'migrationId'

The LINQ expression could not be translated for base property

℡╲_俬逩灬. 提交于 2019-12-10 19:39:22
问题 I have custom OrderBy implementation, it only works for types without inheritance, if I want order by field from base type I got The LINQ expression could not be translated public static IOrderedQueryable<TEntity> OrderBy<TEntity>(this IQueryable<TEntity> source, string orderByProperty, bool desc) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (string.IsNullOrEmpty(orderByProperty)) { throw new ArgumentNullException(nameof(orderByProperty)); } var command = desc

.net core and ef core sql server error provider: SQL Network Interfaces, error: 8 - Protocol not supported

不羁的心 提交于 2019-12-10 19:26:38
问题 I've been trying to develop a new application using .net core in MacOsX using a SQL Server database, but i'm having some problems with the connection because i'm getting the following error: fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HKTRSSNBPQOP": An unhandled exception was thrown by the application. System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not