entity-framework-core

Linq To Entities: String.Contains a list [duplicate]

混江龙づ霸主 提交于 2020-04-18 05:44:14
问题 This question already has answers here : How do you check if a string contains any strings from a list in Entity Framework? (4 answers) Closed 19 days ago . I am using ASP.net Core 3.0 with Entity Framework Core 3.0 and Pomelo.EntityFrameworkCore provider for MySQL , I need to query all the users that are from specific Towns. Lets say for example I have a list of strings called targettedTowns in which I have the following towns var targettedTowns = new List<string>() {"korangi","landhi","zia

Linq To Entities: String.Contains a list [duplicate]

為{幸葍}努か 提交于 2020-04-18 05:43:46
问题 This question already has answers here : How do you check if a string contains any strings from a list in Entity Framework? (4 answers) Closed 19 days ago . I am using ASP.net Core 3.0 with Entity Framework Core 3.0 and Pomelo.EntityFrameworkCore provider for MySQL , I need to query all the users that are from specific Towns. Lets say for example I have a list of strings called targettedTowns in which I have the following towns var targettedTowns = new List<string>() {"korangi","landhi","zia

Unable to hit oracle stored proc using .Net EF(2.2) Core repository pattern

送分小仙女□ 提交于 2020-04-18 00:50:47
问题 ORA-00900: invalid SQL statement This is the error i get when i am trying to hit a stored procedure(in Oracle) from my API. I am using Repository pattern with Entity framework.(EF Core 2.2) This is my call, return FetchWithStoredProcedure("PROC_GETMYPROC", new OracleParameter("PARAM1", OracleDbType.Int32, ParameterDirection.Input) { Value = PageNo }, new OracleParameter("PARAM2", OracleDbType.Int32,ParameterDirection.Input) { Value = PageSize }, new OracleParameter("PARAM3", OracleDbType

Adding a second one-to-one relationship with the same table in entity framework

亡梦爱人 提交于 2020-04-17 10:03:31
问题 I am doing code-first entity framework design. I have a table, Account, which has a property, Supervisor: public class Account { public int Id { get; set; } public Account Supervisor { get; set; } } This works beautifully. However, I wish to add an alternate supervisor to the class: public class Account { public int Id { get; set; } public Account Supervisor { get; set; } public Account AlternateSupervisor { get; set; } } When I run Add-Migration AddAlternateSupervisor, the generated code

How to call stored procedure in Entity Framework Core with input and output parameters using mysql

走远了吗. 提交于 2020-04-16 02:18:07
问题 I am using ASP.net Core 2.2 with Entity Framework core 2.2.6 and Pomelo.EntityFrameworkCore.MySql 2.2.0 for connectivity with MySQL, I have a stored procedure which takes 3 input parameters and 1 output parameter. I am able to call it in MySQL workbench like CALL GetTechniciansByTrade('Automobile', 1, 10, @total); select @total; Now I want to call this using entity framework core, the code I am currently using is var outputParameter = new MySqlParameter("@PageCount", MySqlDbType.Int32);

The seed entity for entity type 'X' cannot be added because the was no value provided for the required property “..ID”

半世苍凉 提交于 2020-04-12 19:02:02
问题 I'm playing wit EF Core 2.1 Preview 2 . I have troubles with HasData (Seed) method in OnModelCreating(ModelBuilder modelBuilder) My model is simple POCO class that has no annotation. public class Tenant { public int TenantID {get; set;} public string Name {get; set;} } in my DbContext inside OnModelCreating method is DB model defined as modelBuilder.Entity<Tenant>(e => { e.HasKey(m => m.TenantID) .HasName("PK_Tenants"); e.Property(m => m.TenantID) .UseSqlServerIdentityColumn(); e.Property(m =

The seed entity for entity type 'X' cannot be added because the was no value provided for the required property “..ID”

依然范特西╮ 提交于 2020-04-12 18:59:08
问题 I'm playing wit EF Core 2.1 Preview 2 . I have troubles with HasData (Seed) method in OnModelCreating(ModelBuilder modelBuilder) My model is simple POCO class that has no annotation. public class Tenant { public int TenantID {get; set;} public string Name {get; set;} } in my DbContext inside OnModelCreating method is DB model defined as modelBuilder.Entity<Tenant>(e => { e.HasKey(m => m.TenantID) .HasName("PK_Tenants"); e.Property(m => m.TenantID) .UseSqlServerIdentityColumn(); e.Property(m =

The seed entity for entity type 'X' cannot be added because the was no value provided for the required property “..ID”

早过忘川 提交于 2020-04-12 18:58:06
问题 I'm playing wit EF Core 2.1 Preview 2 . I have troubles with HasData (Seed) method in OnModelCreating(ModelBuilder modelBuilder) My model is simple POCO class that has no annotation. public class Tenant { public int TenantID {get; set;} public string Name {get; set;} } in my DbContext inside OnModelCreating method is DB model defined as modelBuilder.Entity<Tenant>(e => { e.HasKey(m => m.TenantID) .HasName("PK_Tenants"); e.Property(m => m.TenantID) .UseSqlServerIdentityColumn(); e.Property(m =

Stack overflow when adding an entity with multiple one-to-one relationship with the same table in Entity Framework Core

蹲街弑〆低调 提交于 2020-04-12 07:27:07
问题 I have an issue when adding entities with multiple one-to-one relationship with the same table in Entity Framework Core. Based on this question I have the following things: public class Article { public int Id { get; set; } public int? PreviousId { get; set; } public Article Previous { get; set; } public int? NextId { get; set; } public Article Next { get; set; } } In the OnModelCreating of the DbContext as I have: protected override void OnModelCreating(ModelBuilder modelBuilder) { base

Entity Framework 3.0 Contains cannot be translated in SQL as it was in EF Core 2.2

旧城冷巷雨未停 提交于 2020-04-10 14:04:07
问题 I am trying to migrate a Web API from .NET Core 2.2 to .NET Core 3.0 and I have stumbled across the following: public Dictionary<int, Tag> GetTagMap(IList<int> tagIds = null) { var tags = context.Tag.AsNoTracking(); if (tagIds != null) tags = tags.Where(t => tagIds.Contains(t.TagId)); return tags .ToList() // explicit client evaluation in 3.0 .ToDictionary(t => t.TagId, t => t); } This used to generate a SQL statement similar to this one: SELECT TagId, Name FROM Tag WHERE TagId IN (1, 2, 3)