entity-framework

ADO.Net Entity framework, Fatal error encountered during data read

假如想象 提交于 2020-01-06 19:36:09
问题 I am getting the following error while using MySql with Entity framework. I have set the default connection timeout to 300000 on the connection string of EntityConnectionStringBuilder. How to resolve this in Entity framework? Unhandled Exception: System.Data.EntityCommandExecutionException: An error occurred while reading from the store provider's data reader. See the inner exception for details. ---> MySql.Data.MySqlClient.MySqlException: Fatal error encountered during data read. ---> MySql

How do I automatically add interfaces to EF database first generated entities that have specific properties (column names) by editing T4 .tt templates

折月煮酒 提交于 2020-01-06 19:27:29
问题 I have a around 50 databases that have 150 tables each and working on a search mechanism that would allow to query the tables that have specific columns. Most database structures are same so idea is to generate EF entities and put interfaces behind the entities generated if tables that they are being generated from have specific columns, so that I could later query then on that column. Model will likely be constantly changing so I can't manually add interfaces on tables - here come in T4

EntityFramework Invalid Column Name

孤人 提交于 2020-01-06 19:27:20
问题 UPDATE: Matching both datatypes of BasketID to int does not resolve the issue. Code causing the error: BasketItem duplicateBasketItem = (from thisitem in storeDB.BasketItems where thisitem.sellerSKU == newItem.sellerSKU select thisitem).SingleOrDefault(); The error being thrown: An exception of type 'System.Data.EntityCommandExecutionException' occurred in System.Data.Entity.dll but was not handled in user code {"Invalid column name 'BasketID'."} My Models: public class Basket { [Key] public

EntityFramework Query Returns the same object for relationship

痴心易碎 提交于 2020-01-06 18:35:47
问题 I'm having trouble phrasing the title into something that makes more sense, so I'm going to be a little verbose in my question. I have this EF query: var allSocs = _db.Socs .Where(x => x.Soc6 != null) .Select(x => new SocModel { OccupationalEmploymentStatistics = x.OccupationalEmploymentStatistics .Where(y => y.GeographyId == 25 && y.Release == "2015A01" && y.Naics == "000000") .OrderByDescending(z => z.AnnualWageMedian), Soc6 = x.Soc6, OnetSocs = x.OnetSoc, Name = x.Name, Description = x

EntityFramework Query Returns the same object for relationship

╄→гoц情女王★ 提交于 2020-01-06 18:35:29
问题 I'm having trouble phrasing the title into something that makes more sense, so I'm going to be a little verbose in my question. I have this EF query: var allSocs = _db.Socs .Where(x => x.Soc6 != null) .Select(x => new SocModel { OccupationalEmploymentStatistics = x.OccupationalEmploymentStatistics .Where(y => y.GeographyId == 25 && y.Release == "2015A01" && y.Naics == "000000") .OrderByDescending(z => z.AnnualWageMedian), Soc6 = x.Soc6, OnetSocs = x.OnetSoc, Name = x.Name, Description = x

Parent and Child Link in Entity Framework

微笑、不失礼 提交于 2020-01-06 18:04:31
问题 I'm creating a system web application similar to a Task list. A user can create a Task A User can create a Task within any Task. A User then can create a Task within that Task A User can view the First task and see all the tasks that are linked to that. I have created a simple parent and child relationship. Once I get past the first level i find it impossible? I want to be able to view the original parent task and all the other parent and child tasks within that. So far a Task has an

Database-first approach in Entity Framework without auto generated code

给你一囗甜甜゛ 提交于 2020-01-06 18:04:09
问题 I wonder, if there is any way , to use Database-first approach with manually generated classes (models) in advance(just like Code-first approach), but without using auto-generated code which Entity Framework creates using Database-first approach? I have 3 Classes(first two of them Student and Courses have many to many relationship), which represents models: First one is Student: public class Student { public int StudentID { get; set;} public string Name { get; set;} public DateTime BirthDate

same linq query generate different sql in different projects

喜你入骨 提交于 2020-01-06 15:59:32
问题 Query is: var query = from stokHareket1 in ce.StokHarekets from stokHareket2 in ce.StokHarekets join stok in ce.Stoks on stokHareket1.StokId equals stok.Id where ( stokHareket1.StokId == stokHareket2.StokId ) select new { result = stokHareket1.StokId }; In first project EF version is: 5.0.0 and in the second one: 6.1.3 it gives in first project: SELECT [Extent1].[StokId] AS [StokId] FROM [dbo].[StokHareket] AS [Extent1] INNER JOIN [dbo].[StokHareket] AS [Extent2] ON [Extent1].[StokId] =

How to get latest record for each group using Entity Framework and MySQL including related entity

冷暖自知 提交于 2020-01-06 15:51:22
问题 I am using Entity Framework with a MySQL Database and DbContext. I have an entity "Message" that has a related entity "Sender". (The "Message" also has a related entity "Receiver"). I am trying to write a query that will return only the "latest" message for each receiver. But when I do this, I also want to load the associated "Sender" so that I can get access to one of the Sender's properties (e-mail field) which I need to include in my Data Transfer Object I am returning. "MessageDTO" is the

NinjectControllerFactory FileLoadException Error

谁说胖子不能爱 提交于 2020-01-06 15:19:09
问题 I tried create just example porject and I want use Ninject.I create NinjectControllerFactory.cs like this using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Ninject; using System.Web.Routing; using Moq; using System.Linq; using SportStore.Domain.Entities; using SportStore.Domain.Abstract; using System.Collections.Generic; using SportStore.Domain.Concrete; namespace SportStore.WebUI.Infrastructure { public class