tagged [dbcontext]
Type or namespace name Mock<> could not be found Entity Framework 6
Type or namespace name Mock could not be found Entity Framework 6 I am trying to mock my `DbContext` for writing my unit tests. I saw a tutorial, and tried to do it like the following: But I am gettin...
- Modified
- 10 Aug at 07:56
EF 4.1 OnModelCreating not called
EF 4.1 OnModelCreating not called I have a problem with EF 4.1 not calling `OnModelCreating` so that I can configure tables etc. I have an existing database. Here is my connection string: ```
- Modified
- 25 Jul at 15:59
Mocking EF DbContext with Moq
Mocking EF DbContext with Moq I'm trying to create a unit test for my service with a mocked DbContext. I created an interface `IDbContext` with the following functions: My real context implements this...
- Modified
- 10 May at 17:26
How can I log all entities change, during .SaveChanges() using EF code first?
How can I log all entities change, during .SaveChanges() using EF code first? I'm using . I'm using a base Repository for all my repositories and an `IUnitofWork` that inject to the repositories, too:...
- Modified
- 13 Mar at 03:51
How to Moq Entity Framework SqlQuery calls
How to Moq Entity Framework SqlQuery calls I've been able to mock `DbSet`'s from entity framework with Moq using this [link](http://msdn.microsoft.com/en-gb/data/dn314429.aspx). However, I would now l...
- Modified
- 24 Sep at 10:48
Can you get the DbContext from a DbSet?
Can you get the DbContext from a DbSet? In my application it is sometimes necessary to save 10,000 or more rows to the database in one operation. I've found that simply iterating and adding each item ...
- Modified
- 18 Jul at 01:29
LINQ to Entities only supports casting EDM primitive or enumeration types with IEntity interface
LINQ to Entities only supports casting EDM primitive or enumeration types with IEntity interface I have the following generic extension method: ``` public static T GetById(this IQueryable collection, ...
- Modified
- 16 Apr at 04:51
How to fix the datetime2 out-of-range conversion error using DbContext and SetInitializer?
How to fix the datetime2 out-of-range conversion error using DbContext and SetInitializer? I'm using the DbContext and Code First APIs introduced with Entity Framework 4.1. The uses basic data types s...
- Modified
- 1 Jul at 19:17
How do you configure the DbContext when creating Migrations in Entity Framework Core?
How do you configure the DbContext when creating Migrations in Entity Framework Core? Is there way that dependency injection can be configured/bootstrapped when using Entity Framework's migration comm...
- Modified
- 7 Sep at 11:45
c# entity framework: correct use of DBContext class inside your repository class
c# entity framework: correct use of DBContext class inside your repository class I used to implement my repository classes as you can see below ``` public Class MyRepository { private MyDbContext _...
- Modified
- 9 Oct at 14:48
DbContext won't keep connection open for re-use
DbContext won't keep connection open for re-use I'm trying to reuse an existing database connection so that I can do multiple database operations using a `TransactionScope` without invoking MSDTC. Ent...
- Modified
- 13 Oct at 16:49
DBContext disposing doesn't change the number of opened connections
DBContext disposing doesn't change the number of opened connections In highload legacy application I've found tons of code which just creates new DBContext, then makes request and doesn't dispose the ...
- Modified
- 21 Sep at 03:27
How to extend DbContext with partial class and partial OnModelCreating method in EntityFramework Core
How to extend DbContext with partial class and partial OnModelCreating method in EntityFramework Core I'm using EF Core and DatabaseFirst approach. My dbContext is created automatically by `Scaffold-D...
- Modified
- 25 Sep at 18:3
EF Core / DbContext > Map custom type as primary key
EF Core / DbContext > Map custom type as primary key Using EF Core I'm trying to build a model for the follow entity.
- Modified
- 2 Apr at 07:50
Entity Framework code first: How to ignore classes
Entity Framework code first: How to ignore classes This is similar to questions [here](https://stackoverflow.com/questions/7886672/how-to-ignore-entity-in-entity-framework-code-first-via-setup) and [h...
- Modified
- 23 May at 11:55
What do I need to add into OnModelCreating(DbModelBuilder modelBuilder) function to define relations between Person and Role?
What do I need to add into OnModelCreating(DbModelBuilder modelBuilder) function to define relations between Person and Role? I'm using EntityFramework version 5.0 in WinForms project, .net 4.5. I hav...
- Modified
- 15 Jul at 00:10
Getting "The entity type <model> is not part of the model for the current context."
Getting "The entity type is not part of the model for the current context." I am having this issue updating my database 1 column at a time in asp.net using web api. I am trying to query a PUT to just ...
- Modified
- 14 Mar at 02:25
Configure multiple database Entity Framework 6
Configure multiple database Entity Framework 6 In my solution I have 2 projects that use Entity Framework 6. Each points to a different database, both using the same data provide - SQL Server. A third...
- Modified
- 20 Jun at 09:12
Refreshing Sql Connection Azure AD access token inside long-lived Entity Framework Context
Refreshing Sql Connection Azure AD access token inside long-lived Entity Framework Context I'm trying to set up a few .NET applications to use certificate-based authentication to Azure Active Director...
- Modified
- 14 Sep at 00:19
The entity type <type> is not part of the model for the current context
The entity type is not part of the model for the current context I am getting into the Entity Framework, but I am unsure if I am missing a critical point in the code-first approach. I am using a gener...
- Modified
- 19 Dec at 18:34
EF (entity framework) usage of "using" statement
EF (entity framework) usage of "using" statement I have a project on MVC. We chose EF for our DB transactions. We created some managers for the BLL layer. I found a lot of examples, where "`using`" st...
- Modified
- 3 May at 19:37
More than one DbContext was found
More than one DbContext was found I am implementing a code first database using AspCore 2. I have a "DataContext.cs" that goes like this: ``` public class ApplicationUser : IdentityUser { public str...
- Modified
- 28 Aug at 22:21
The operation cannot be completed because the DbContext has been disposed using MVC 4
The operation cannot be completed because the DbContext has been disposed using MVC 4 I know that this Question is asked so many times. I have read and implemented all solution but didn't get success....
- Modified
- 19 Jan at 03:24
Can I clone an IQueryable to run on a DbSet for another DbContext?
Can I clone an IQueryable to run on a DbSet for another DbContext? Suppose I have built up, through some conditional logic over many steps, an `IQueryable` instance we'll call `query`. I want to get a...
- Modified
- 28 Jun at 17:18
Correct use of Microsoft.AspNet.Identity 2.0
Correct use of Microsoft.AspNet.Identity 2.0 I'm lost using the authentication method that comes with MVC 5 Template. I had the need to include the CreateBy user in an entity called client, so after s...
- Modified
- 4 Dec at 23:58