entity-framework-core-2.1

Reference to an ITVF raises a “second operation started on this context before a previous operation completed” exception

爷,独闯天下 提交于 2019-12-02 00:55:09
问题 I am attempting to reference an Inline Table-Valued Function (ITVF) in a Linq query: var results = await ( from v in _context.Vehicles from r in _context.UnitRepairStatus(v.VehicleNumber) <-- ITVF reference orderby v.VehicleNumber select new FooViewModel { ID = v.ID, VehicleNumber = v.VehicleNumber, InRepair = Convert.ToBoolean(r.InRepair) <-- ITFV field } ).ToListAsync(); When the query runs, it generates an error: InvalidOperationException: A second operation started on this context before

Use a Inline Table-Valued Functions with Linq and Entity Framework

白昼怎懂夜的黑 提交于 2019-12-01 21:26:55
I created an Inline Table-Valued Functions (ITVF) in SQL Server that returns a table of values (query simplified for discussion purposes): CREATE FUNCTION dbo.VehicleRepairStatus() RETURNS TABLE AS RETURN SELECT VehicleID, CurrentStatus FROM VehicleRepairHistory ... Which I can reference in a query: SELECT v.ID, v.Name, r.CurrentStatus FROM Vehicle v LEFT OUTER JOIN dbo.VehicleRepairStatus() r on v.ID = r.VehicleID I'd like to be able to use it in Linq query: var vehicles = await _databaseContext.Vehicles .Join() // join ITVF here? .Where(v => v.Type == 'Bus' ) .OrderBy(v => v.Name)

Reference to an ITVF raises a “second operation started on this context before a previous operation completed” exception

社会主义新天地 提交于 2019-12-01 21:14:53
I am attempting to reference an Inline Table-Valued Function (ITVF) in a Linq query: var results = await ( from v in _context.Vehicles from r in _context.UnitRepairStatus(v.VehicleNumber) <-- ITVF reference orderby v.VehicleNumber select new FooViewModel { ID = v.ID, VehicleNumber = v.VehicleNumber, InRepair = Convert.ToBoolean(r.InRepair) <-- ITFV field } ).ToListAsync(); When the query runs, it generates an error: InvalidOperationException: A second operation started on this context before a previous operation completed. Any instance members are not guaranteed to be thread safe. with a

Entity Framework Core / SQLite: GroupJoin after Join “flattens” results

女生的网名这么多〃 提交于 2019-12-01 10:32:41
Using Entity Framework Core 2.1 and an SQLite database, I get different behaviour from a LINQ GroupJoin if I use it after another Join. It is not clear if this is a bug or if there is something I am overlooking. I have created a minimal VS2017 project to reproduce this, which can be found here: https://gitlab.com/haddoncd/EntityFrameworkGroupJoinIssue In this example, I get one object for each row in the Blog table, each containing multiple PostTitles: db.Blogs .GroupJoin( db.Posts, s => s.BlogId, p => p.BlogId, (s, ps) => new { s.BlogId, s.BlogTitle, PostTitles = ps.Select(p => p.PostTitle),

Entity Framework Core / SQLite: GroupJoin after Join “flattens” results

*爱你&永不变心* 提交于 2019-12-01 07:32:38
问题 Using Entity Framework Core 2.1 and an SQLite database, I get different behaviour from a LINQ GroupJoin if I use it after another Join. It is not clear if this is a bug or if there is something I am overlooking. I have created a minimal VS2017 project to reproduce this, which can be found here: https://gitlab.com/haddoncd/EntityFrameworkGroupJoinIssue In this example, I get one object for each row in the Blog table, each containing multiple PostTitles: db.Blogs .GroupJoin( db.Posts, s => s

Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project

六月ゝ 毕业季﹏ 提交于 2019-12-01 03:52:33
I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the command Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. This is the command I am using to scaffold the database model: Scaffold-DbContext "server=localhost;port=3306;user=root;password=1234

Entity Framework Core - EF Core 2.2 - 'Point.Boundary' is of an interface type ('IGeometry')

◇◆丶佛笑我妖孽 提交于 2019-11-30 04:46:35
问题 I am trying the new functionality with EF Core 2.2. It is based on the following article. "Announcing Entity Framework Core 2.2" https://blogs.msdn.microsoft.com/dotnet/2018/12/04/announcing-entity-framework-core-2-2/ I installed the following Nuget package. I added the following to my model. using NetTopologySuite.Geometries; //New as of EF.Core 2.2 //[Required] //[NotMapped] public Point Location { get; set; } During my application startup I get the following error in my Database Context on

Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project

[亡魂溺海] 提交于 2019-11-30 02:20:00
问题 I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the command Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. This is the command I am using

How to uninstall EF Core tables? Or how to remove all migrations ? Or how to call `dotnet ef database update 0` from user code?

南笙酒味 提交于 2019-11-28 14:30:26
I'm developing web app and near it small command line application that install ef core tables in the DB. Last can be done calling dbContext.Database.Migrate(); and this works. Now I want to provide unistall option (with this app). But how to remove migrations (means call functionality of dotnet ef database update 0 from my code) ? It could be not one command call (as it was in case with dbContext.Database.Migrate(); ). But snippet with loop through all migrations in migrations assembly and call of 'Downs'. EF Core provides publicly only the dbContext.Database.Migrate(); extension method used

What could cause `UserManager` to return the wrong user?

二次信任 提交于 2019-11-28 11:49:31
Something rather scary is happening on my ASP.NET Core 2.1.0 MVC site. While I was browsing, all of a sudden it shows I am logged in as a different user (who also happens to be browsing the site at that time). I can't pinpoint whether there is a specific use case that triggers this, but this has happened twice now. Navigating to other pages still shows I am logged in as the other user. It even seems I take over the claims of the user I am incorrectly logged in as. My question is: what could make this happen? EDIT : I have since changed userManager and notificationService to 'scoped' and this