ef-core-2.0

ef core 2.0 scaffold-dbcontext custom namespace

馋奶兔 提交于 2021-02-19 06:46:06
问题 I am using the ef core 2.0 CLI command scaffold-dbcontext to reverse engineer poco classes from an existing DB (database first). I want to put the generated classes from scaffold-dbcontext in a "Model" folder within my project but I want the namespace of the classes to be something different than "MyProjectName.Model". For example, I want the scaffold-dbcontext generated files to live in the Model folder but I want the namespace of the genereated files to be "MyProjectName.Entities". Is there

EF Core 2.0 OwnsOne column prefix

这一生的挚爱 提交于 2021-02-18 00:50:50
问题 When using OwnsOne to map complex types, the sql column name is prefixed with the attribute name. Is it possible to specify the prefix name in the mapping? This is my mapping: e.OwnsOne(x => x.Attributes, cb => { cb.OwnsOne(a => a.Supplier); }); I would like the sql column to be prefixed with "Attr_" Instead of "Attributes_". Is this possible? 回答1: Ivan Stoev's answer from the question comments: It has to be done through the corresponding OwnsOne builder action argument. e.g. .OwnsOne(e => e

ASP.NET Core stored procedure not working in loop

浪尽此生 提交于 2021-02-10 08:16:51
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

Deadly 提交于 2021-02-10 08:14:56
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

寵の児 提交于 2021-02-10 08:14:25
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

旧街凉风 提交于 2021-02-10 08:13:14
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

醉酒当歌 提交于 2021-02-10 08:10:48
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

ASP.NET Core stored procedure not working in loop

Deadly 提交于 2021-02-10 08:10:41
问题 I want to use a stored procedure for DB query, it works for a single query, but in loop, it executes like in first loop iteration. var getAutoResults = new List<List<Karat_getAutoData_Result>>(); foreach (var elem in meas) { getAutoResults.Add(await _context.KaratGetAutoDataResults .FromSql($"dbo.Karat_getAutoData @MeasurementId = {elem.MeasurementId}, @CalcRequestId = {null}") .ToListAsync()); } After this I get N times the same results, but all ids are different. 回答1: I can resolve it only

Unexpected behaviour with Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ForEachAsync<T>()

送分小仙女□ 提交于 2021-02-07 14:49:27
问题 Here are the steps to reproduce. The below program copies 10,000 rows from one SQL table to another using .Net Core console app and EF Core. The program inserts records in 100 batches, and (this is important!) it creates a new instance of DbContext for each insert. 1) Create SQL Server database, and the "Froms" and "Tos" tables: create table Froms ( Id int identity(1, 1) not null, Guid [uniqueidentifier] not null, constraint [PK_Froms] primary key clustered (Id asc) ) go create table Tos ( Id

Unexpected behaviour with Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ForEachAsync<T>()

让人想犯罪 __ 提交于 2021-02-07 14:44:50
问题 Here are the steps to reproduce. The below program copies 10,000 rows from one SQL table to another using .Net Core console app and EF Core. The program inserts records in 100 batches, and (this is important!) it creates a new instance of DbContext for each insert. 1) Create SQL Server database, and the "Froms" and "Tos" tables: create table Froms ( Id int identity(1, 1) not null, Guid [uniqueidentifier] not null, constraint [PK_Froms] primary key clustered (Id asc) ) go create table Tos ( Id