ef-core-2.0

AutoFac / .NET Core - Register DBcontext

a 夏天 提交于 2020-07-18 03:18:06
问题 I have a new .NET Core Web API project that has the following projects structure: API -> Business / Domain -> Infrastructure The API is very thin with only the API methods. The Business / Domain layer has all my business logic. And finally, my Infrastructure layer has my DB classes using EF Core 2.0. I know using .NET Core built-in Dependency Injection I can add a reference from the API project to the Infrastructure project, then add the following code in the StartUp.cs file: services

AutoFac / .NET Core - Register DBcontext

别等时光非礼了梦想. 提交于 2020-07-18 03:16:16
问题 I have a new .NET Core Web API project that has the following projects structure: API -> Business / Domain -> Infrastructure The API is very thin with only the API methods. The Business / Domain layer has all my business logic. And finally, my Infrastructure layer has my DB classes using EF Core 2.0. I know using .NET Core built-in Dependency Injection I can add a reference from the API project to the Infrastructure project, then add the following code in the StartUp.cs file: services

AutoFac / .NET Core - Register DBcontext

时光总嘲笑我的痴心妄想 提交于 2020-07-18 03:16:13
问题 I have a new .NET Core Web API project that has the following projects structure: API -> Business / Domain -> Infrastructure The API is very thin with only the API methods. The Business / Domain layer has all my business logic. And finally, my Infrastructure layer has my DB classes using EF Core 2.0. I know using .NET Core built-in Dependency Injection I can add a reference from the API project to the Infrastructure project, then add the following code in the StartUp.cs file: services

Does EF core compares value to include columns in update statement?

烈酒焚心 提交于 2020-06-28 05:25:17
问题 I have the following code var dbContext = Setup.ConfigureDBContext(); var wo = await dbContext.WorkOrders.Where(x => x.WorkOrderID == 88).SingleOrDefaultAsync(); var t = wo.Confidence; wo.ModifiedDateTime = DateTime.UtcNow; wo.Confidence = t; await dbContext.SaveChangesAsync(); in the above query i am assigning the same Confidence but changing the ModifiedDateTime EF generates the following SQL exec sp_executesql N'SET NOCOUNT ON; UPDATE [WorkOrders] SET [ModifiedDateTime] = @p0 WHERE

may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints

Deadly 提交于 2020-05-27 12:03:28
问题 Entity Framework Core Throwing error while doing update-database Error:- Introducing FOREIGN KEY constraint 'FK_UserRoleRelationship_UserRoels_ParentUserRoleId' on table 'UserRoleRelationship' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. public class UserRoleRelationship { [Key] public int Id { get; set; } [Required] public Guid UserRoleRelationshipId { get; set; }

may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints

时间秒杀一切 提交于 2020-05-27 12:02:33
问题 Entity Framework Core Throwing error while doing update-database Error:- Introducing FOREIGN KEY constraint 'FK_UserRoleRelationship_UserRoels_ParentUserRoleId' on table 'UserRoleRelationship' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. public class UserRoleRelationship { [Key] public int Id { get; set; } [Required] public Guid UserRoleRelationshipId { get; set; }

may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints

浪尽此生 提交于 2020-05-27 12:01:31
问题 Entity Framework Core Throwing error while doing update-database Error:- Introducing FOREIGN KEY constraint 'FK_UserRoleRelationship_UserRoels_ParentUserRoleId' on table 'UserRoleRelationship' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. public class UserRoleRelationship { [Key] public int Id { get; set; } [Required] public Guid UserRoleRelationshipId { get; set; }

may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints

时光总嘲笑我的痴心妄想 提交于 2020-05-27 12:01:29
问题 Entity Framework Core Throwing error while doing update-database Error:- Introducing FOREIGN KEY constraint 'FK_UserRoleRelationship_UserRoels_ParentUserRoleId' on table 'UserRoleRelationship' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. public class UserRoleRelationship { [Key] public int Id { get; set; } [Required] public Guid UserRoleRelationshipId { get; set; }

EF Core 2.2 - Cannot project while using IQueryable

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-17 08:50:27
问题 This is the method in my generic repository: public async Task<TEntity> GetByCondition(Expression<Func<TEntity, bool>> predicate, Func<DbSet<TEntity>, IQueryable<TEntity>> baseQuery = null) { IQueryable<TEntity> q = _context.Set<TEntity>(); if (baseQuery != null) { q = baseQuery(_context.Set<TEntity>()); } return await q.Where(predicate).FirstOrDefaultAsync(); } This is the usage in my business logic: Expression<Func<Countries, bool>> whereExpr = x => x.SlugHebrew == slug || x.SlugEnglish ==