Questions tagged [dbset]

224 questions
0
votes
1 answer

What's the purpose of DbSet.Create() if not to properly initialize the identity columns?

In working with Entity Framework Database First, why is it that issuing the Create method in any of my DbContext Sets creates an instance of the set's entity without incrementing its Identity columns ? Considering I build all entities I want to add…
Veverke
  • 9,208
  • 4
  • 51
  • 95
0
votes
0 answers

Override DbSet - Remove functionality

So I'm trying to override the DbSet from EF but it's not working as I thought it would. The member 'IQueryable.Provider' has not been implemented on type 'RequestedDocumentDbSet' I only want to override the Remove and RemoveRange method. Is this…
Tikkes
  • 4,599
  • 4
  • 36
  • 62
0
votes
1 answer

Apply a dynamically-built expression on non-generic DbSet

I have the following scenario: I have an unknown at compile time DbSet, which I get it via its type like: DbSet entities = _repository.Context.Set(myType) I have a dynamically-built expression of a given type, Expression myFilter; //built as an…
Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59
0
votes
1 answer

DbSet content differs from database content

I'm using Entity Framework with Code First in C#. I'm trying to display the contents of one of the tables from my database using the DbSet but it differs from the actual content of that table in the database. I'm looking at the DbSet and the table…
moondaisy
  • 4,303
  • 6
  • 41
  • 70
0
votes
1 answer

code first generated database cannot be seen in sql server but it acts as if it has been created

I have a WCF which makes call to my EF. I have made the WCF my start up project and one of the services in there a start up file. When i run this project and pass in the right parameter as what i have in my Seed method, i get an object back from…
floormind
  • 1,868
  • 5
  • 31
  • 85
0
votes
1 answer

Reflecting over IDbSets using base class

I have a DataContext derived class that has many IDbSets that are subclasses of a base class: public class BaseClass { public int Id {get; set;} public int Length {get; set;} public int Height {get; set;} } public class Derived1 :…
BlackICE
  • 8,816
  • 3
  • 53
  • 91
0
votes
1 answer

Updating many DbSet objects at one time

I am coding a MVC 5 internet application and am using Entity Framework 6. I have an Asset object that can be referenced in many Image objects. When I edit an Asset object, I need to update a DateTime object that is stored in all referenced Image…
Simon
  • 7,991
  • 21
  • 83
  • 163
0
votes
1 answer

Using IQueryable for DbSets

I am coding a MVC 5 internet application, and have a question in regards to using IQueryable. If I retrieve a set of DbSet objects as an IQueryable, and I do not reference some of the properties in each DbSet object, are the values for these…
Simon
  • 7,991
  • 21
  • 83
  • 163
0
votes
1 answer

Is it possible to convert ObjectSet to DbSet in Entity Framework 6?

I am working on upgrading a WPF application from using .Net4/EF 4.4 to .Net4.5/EF 6.1. After the upgrade I will use DbContext (since there was no POCO-generator for ObjectContext). The application use a Repository/UnitOfWork-pattern to access…
GHauan
  • 189
  • 1
  • 13
0
votes
1 answer

Entity Framework dynamic model not working

I'm starting working with the Entity Framework 6 and got a problem with dynamic models. I have the following model: public class EF6 { public Guid Guid { get; set; } public int Int2 { get; set; } public string Str { get; set; } …
BendEg
  • 20,098
  • 17
  • 57
  • 131
0
votes
2 answers

Dbset.Add(entity) assigns an ID and this results in a exception

For the following classes : public Car { public int ID { get; set; } public string Brand {get; set; } } Normally when we do : Car c = new Car { Brand = "Jaguar" } ; // Point A context.Cars.Add(c); // Point B context.SaveChanges() // Point…
tobiak777
  • 3,175
  • 1
  • 32
  • 44
0
votes
1 answer

DBSet dynamically register using interface

I want to create a code block which register DBsets dynamically. I decide to use an empty Interface to catch classes which implement the interface. Here is my code block. var entityMethod = typeof(DbModelBuilder).GetMethod("Entity"); …
MehmetF
  • 61
  • 1
  • 14
0
votes
1 answer

Referencing my Models in DAL

Happy New Year everyone. Ok, i'm trying to create a 3 tier application and i have my references in the following order UI -> BLL -> DAL. The question is. The problem i'm having is with the Dbset. Because i have no reference to my models within my…
0
votes
1 answer

How does Entity framework implement deleting parent and a child record on the ame SaveChanges()

I have the following two entity sets representing Dept & Emp:- public partial class Dept { public Dept() { this.Emps = new HashSet(); } public int DeptID { get; set; } public string Name { get; set; } public…
0
votes
1 answer

Do generated IDs of DbSet always represent position?

When adding elements to a newly created DbSet, are IDs always generated from 1 to (number of elements)... or do I have to add some code to make sure this happens... The real problem is that I want to have public DbSet Students { get; set;…
porente
  • 371
  • 2
  • 14