The DbContext API first shipped with Entity Framework version 4.1 and provides a more productive surface for working with the Entity Framework and can be used with the Code First, Database First, and Model First approaches.

learn more… | top users | synonyms

0
votes
1answer
30 views

DbContext disposed error

I have tried the internet, but could not find a good answer. Here is the code which is having the problem private void LoadRecords() { var data = from record in model.Records ...
0
votes
2answers
26 views

Use DbContext in repository

I used repository and UnitOfWork Design pattern in my project.I have some common CRUD function in generic repository that all repository inherit that.In act I have one repository per entity in ...
0
votes
0answers
17 views

How can I log all entities change, during .SaveChanges() using EF code first?

I'm using EF code first. Also i'm using a base Repository for all my repositories and an IUnitofWork that inject to the repositories: public interface IUnitOfWork : IDisposable { ...
0
votes
0answers
11 views

Metadata conflict between two unrelated WCF Data Services?

I have a solution structured as follows: Solution DataServiceForExternalWebsite.csproj (Web Application) Data\Model.edmx (With ExternalDataContext as the ContainerName) ...
0
votes
0answers
34 views

MVC 4 EF 5 Code First and deploying to azure cause twice seeding

I am trying to add my website with database created by entity framework code first to azure. Everything seems ok but data which I had in Seed I have twice. I tried to wrote steps which I did: I ...
0
votes
0answers
14 views

Migrate EF 4 with ObjectContext to EF5 and DbContext APIs

We implemented a web application using EF 4.0 and ObjectContext. Now we would like to upgrade it to Ef 5 to get benefit of the performance improvements and new features, as described in Julie Lerman's ...
0
votes
1answer
11 views

InvalidOperationException (collection is already set to an EntityCollection) after template modified that all properties are virtual

Default tt for DbContext entities adds in entity's constuctor the initialization code for collection proeprties. Each collection is assigned empty HashSet For scalar entity properties tt has this ...
1
vote
0answers
11 views

Issue with EF 4.1 Pre-Compiled View Generation

I have a Entity Framework 4.1 DbContext based model. I am using a PocoModelGenerator.tt file to generate my entities. I found that querying a 20,000 row SQL table takes around 5 seconds from my code ...
0
votes
1answer
9 views

Dangling foreign keys for dependent entities

I use DbContext. Look at these two variants of code: var context = new MyEntities(); context.Configuration.LazyLoadingEnabled = false; var item = context.Items.OrderBy( i => i.Id).First(); var ...
1
vote
3answers
47 views

EF DbContext. How to avoid caching?

Spent a lot of time, but still cann't understand how to avoid caching in DbContext. I attached below entity model of some easy case to demonstrate what I mean. The problem is that dbcontext caching ...
0
votes
2answers
26 views

What is the point of DbContext proxy objects?

I'm trying to learn more about Entity Framework 5 and the DbContext, and I have a question about entity proxies. Given a generated Alert entity class: public partial class Alert { public Alert() ...
0
votes
0answers
7 views

How to reload DbContext collections bound to UI

I'm using a Code First DbContext that has master-detail relations bound to UI using four binding sources. This needs to be refreshed from the database periodically, so I need to be able to reload the ...
2
votes
3answers
42 views

Format the dbcontext sql query

I have a dbContext set up that works when using the .find() command to search on the key value. For example, the following statement will return the mass value for the key that matches UnitID passed ...
0
votes
0answers
13 views

Extending entity framework model: how to get the DBContext?

Given some models in Entity Framework (autogenerated by db): Partial Public Class Students Public Property SchoolId As String And Partial Public Class Schools Public Property SchoolId As String ...
0
votes
1answer
33 views

How create multiple db context intances by conntecting strings?

In C#, MVC code first application I have public class CarContext : DbContext { } class in first version of application. And connection string is like <add name="CarContext" ...

1 2 3 4 5 40
15 30 50 per page