I use Entity Framework 6 and i currently have a query with many includes which loads about 1200 entities into the dbContext. Loading the entities seems to be quite slow as the query takes almost a minute. Is there anything I can do about the performance? ...
I am developing an application in asp.net mvc. I use entity framework as ORM. I have a problem. To use javascript unobstrusive validation, I need to add annotation to model objects. For example; [Required], [EMailAddress]. But when we add something to the...
I had a bug in my code and eventually managed to track it down to my usage of an IQueryable statement, however the implication of what happened leaves me with a few questions I was hoping someone with more knowledge on Entity Framework could shed some lig...
How do I create an in memory version of a DbContext for testing in entity framework 6? I cannot use .NET core for this project, it must be e.f. 6. I already have a custom db context created that connects to sql server and works great....Doing this in .NET...
I came across some lines of code today that, boiled down, amounts to something like this:...using (var db = new AppDbContext())
{
var foo = await db.Foos
.Where(m => m.Name == "BuzzBaz" )
.FirstAsync();
foo.Name = "Quxx";
db.S...
I have the following method:... public bool Method(object obj){
var objType = obj.GetType();
//do some reflection to get obj properties for some logic
...
if(someCondition) {
obj = null;
return false;
}
if(con...
I have a weird situation regarding EntityFramework 6 with .NET 4.5 (C#)....I have (almost) the same query in two different places. But one time it queries agains the database and the second time it queries against in-memory objects. And since I'm filterin...
I have 2 Entity classes, Product and Category. Each product has a category, and a category contain many products: ...public class Category
{
public int ID { get; set; }
public string Name { get; set; }
public Category(string n...
Whenever I call ...databaseContext.SaveChanges()..., before data is saved by Entity Framework, I need all objects and their child classes to have the ...CreatedOn... field populated with ...DateTime.Now().......Details: I have a ...BaseEntity... class tha...
I am using EF6 Oracle.ManagedDataAccess v18.3.0, database first concept (edmx). The problem is that Oracle table stores Number that has higher precision (38 digits), that the default Decimal C# data type to which the oracle Number is mapped. Decimal has p...
I'm using EF6 Code First to work.
First I created 2 class:...public class Course
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<Tag> Tags { get; set; }
}
public class Tag
{
public int Id { get; set; }
...
What I'm trying to do is implementing the model in Code First for this basic entities:...public class CompanyType{
public int Id {get;set;}
public string CompanyType {get;set;}
}
public class Company{
public int Id {get;set;}
public str...
I have a structure of cart that contains orders that contains order items that contains order sub items. All this structure also work with logical delete. I have on each level a data delete property. I use Entity Framework 6.2.4...So I have C-O-OI-OSI...H...
I updated from EF6.2 to EF6.4 and I encountered this exception chain:...[VerificationException: Operation could destabilize the runtime.]
System.Data.Entity.Core.Metadata.Edm.FacetDescription.Validate(String declaringTypeName) +70
System.Data.Entity...
I have an asp.net core 2 webapplication with EF 6. The way I have been using db context so far is using dependency injection provided by asp.net core to inject the context into controllers:...protected DbContext dbContext;
public BaseController(DbContext...
How can i select data from two tables using SQL query using ef core.
Below are two tables... public class Category
{
public int Id { get; set; } // Don't want to return this.
public string Name { get; set; } // Only want to return this...
I'm using a LinQ query that looks like this...public List<TEntity> GetEntities<TEntity>(int[] ids)
{
var someDbSet = new DbSet<TEntity>();
var resultQ = someDbSet.Where(t => !ids.Any() || ids.Contains(t.ID)); //<= crashing line
return result...
I've got a data context with a list of pipelines. I want to query one pipeline containing all its properties and sub-properties. One pipeline has got a list of stages. The base stage type is abstract. In the list, there can be stages of different child ty...
Scenario:...I have a Gridview with some records which read from SQL Database, each record of Gridview has a button that use ...CommandName... and ...CommandArgument... with sending ...'<%#Eval("UserId")%>'... to detecting each record with calling them in ...