zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

59 results in tag: unit-testing

Test Entity Framework Find Method

I'm trying to test the that the ...GetSystem(int id)... method in ...SystemService.cs... returns the correct value, but can't seem to figure out how to get everything to play well together. It seems that no matter what I do, ...GetSystem()... always retur...
asp.net-web-api c# entity-framework entity-framework-6 unit-testing
asked by Steve Platz

How to unit test async methods of Entity Framework with a multiple clauses

I'm trying to unit test an async method in EF 6.0.2 with Moq 4.0.10827 and I'm getting blocked in what appears to be a casting issue....The following works fine:...public async Task<List<Testimonial>> GetByEventIdAsync(int eventId) { var query = from ...
c# entity-framework entity-framework-6 unit-testing
asked by Dan Friedman

How are people unit testing with Entity Framework 6, should you bother?

I am just starting out with Unit testings and TDD in general. I have dabbled before but now I am determined to add it to my workflow and write better software....I asked a question yesterday that kind of included this, but it seems to be a question on its...
c# entity-framework entity-framework-6 unit-testing
asked by Modika

Unable to use existing database in unit tests with Effort framework

I am trying to write test using a database, hosted in Azure SQL, with ...Effort... framework on Entity Framework 6....When executing the following code, an exception is thrown: ...[ClassInitialize] public static void ClassInitialize(TestContext context) {...
c# effort entity-framework entity-framework-6 unit-testing
asked by Lena Kaplan

EF6 DbSet<T> returns null in Moq

I have a typical Repository Pattern setup in my application with a ...DbContext... (EF6):...public class MyDbContext : EFContext<MyDbContext> { public MyDbContext () { } public virtual DbSet<CartItem> Cart { get; set; } ...and a repository:...pu...
c# entity-framework entity-framework-6 moq unit-testing
asked by Stephen Collins

unit testing with effort for entity framework 6 with computed values

Using effort EF6 with code first does not populate computed values. I have a datetime field (FechaCreacion) that is computed. How can I emulate it in Effort, so It is populated with DateTime.Now after savingChanges() ?...This post ...Using Effort (EF Test...
effort entity-framework entity-framework-6 unit-testing
asked by nerlijma

How can I reset an EF7 InMemory provider between unit tests?

I am trying to use the EF7 InMemory provider for unit tests but the persistent nature of the InMemory database between tests is causing me problems....The following code demonstrates my issue. One test will work and the other test will always fail. Even t...
entity-framework-core mstest unit-testing
asked by Sailing Judo

How to rollback EF 7 migrations programmatically?

I would like to write a unit test which migrates to the latest schema then tears back down to nothing....For the migration I can do :...db.Database.Migrate(); ...but how to I rollback?
c# database-migration entity-framework entity-framework-core unit-testing
asked by sprocket12

Mocking DbContext in Entity Framework 6.1

I have found a number of examples that show (apparently) a clear working example of mocking DbContext with EF 6, however, none of them seem to work for me and I am not entirely sure why....This is my unit test code that sets up the mock;...var mockData = ...
c# entity-framework entity-framework-6 moq unit-testing
asked by ChrisBint

How to mock an async repository with Entity Framework Core

I'm trying to create a unit test for a class that calls into an async repository. I'm using ASP.NET Core and Entity Framework Core. My generic repository looks like this....public class EntityRepository<TEntity> : IEntityRepository<TEntity> where TEntit...
asp.net-core c# entity-framework-core moq unit-testing
asked by Jed Veatch

How could I Mock the FromSql() method?

I was wondering is there any way other than building a wrapper for mocking the ...FromSql...? I know this method is static, but since they added things like ...AddEntityFrameworkInMemoryDatabase... to entity framework core, I thought there might be a solu...
c# entity-framework-core moq unit-testing
asked by Hamid Mosalla

Converting IQueryable to implement IAsyncEnumerable

I have a query in a method:...private readonly IEntityReader<Customer> _reader; public async Task<IEnumerable<Customer>> HandleAsync(GetCustomer query) { var result = _reader.Query() .Include(customer => customer.Organization) .Where(...
c# entity-framework-core moq unit-testing
asked by janhartmann

c# mocking EF6 context and dealing with auto increment primary keys

Has anyone found a good way to get auto-increment primary keys in a mocked context to work when testing service layers?...In most cases, seeding the primary key as part of the data to test is possible. But many service layer methods deal with creating mul...
c# entity-framework entity-framework-6 mocking unit-testing
asked by Michael Brown

Unit Test with Moq - Value can not be null

I'm using EF6. The generated code is something like:...public partial class MyDataContext : DbContext { public MyDataContext() : base("name=mydata") { } public virtual DbSet<Book> Books { get; set; } } ...Then I have a generic repository ...
c# entity-framework entity-framework-6 moq unit-testing
asked by notlkk

How do I write unit tests for ASP.NET Core controllers that actually use my Database Context?

There seems to be little information about how to write good unit tests for ...actual... ASP.NET Core controller actions. Any guidance about how to make this work for real?
asp.net-core asp.net-mvc c# entity-framework-core unit-testing
asked by theutz

Validating entities using data annotations or fluent api in EF 7.0 (In Memory)

I can't verify and test my database by in memory providers. for example I set these properties to required : ...public abstract class Log { #region Properties public Guid Id { get; set; } [Required] public string ClientIp { get; set; } ...
data-annotations entity-framework-core in-memory-database mstest unit-testing
asked by paradise_human

Using Moq with Entity Framework 6 - Mocking Include and Where

I'm trying to create some In-Memory ...dbContext... mocks using ...Moq... and using ...EntityFramework.Testing.Moq... extension methods:...https://github.com/scott-xu/EntityFramework.Testing...I'm hitting a brick wall when I'm trying to unit test my eager...
c# entity-framework entity-framework-6 moq unit-testing
asked by garfbradaz

ASP Boilerplate problems using Effort in unit testing with EFProf (Entity Framework Profiler)

Having issues using EFProf (...http://www.hibernatingrhinos.com/products/EFProf...) with ASP Boilerplate (...http://www.aspnetboilerplate.com/...). ...For unit testing, ASP Boilerplate uses Effort (...https://github.com/tamasflamich/effort...) for mockin...
asp.net-boilerplate effort entity-framework entity-framework-6 unit-testing
asked by Todd Brooks

Unit Test with Effort EF6 with Async Methods

I'm trying to setup Unit tests for this. But every example I've seen that actually works is this type of setup. It will work this way....//Setup DBContext public MyContext(DbConnection connection) : base(connection, true){} //Have some service that gets p...
c# effort entity-framework entity-framework-6 unit-testing
asked by KryptoBeard

Entity Framework Core: Log queries for a single db context instance

Using EF Core (or any ORM for that matter) I want to keep track of the number of queries the ORM makes to the database during some operation in my software....I've used SQLAlchemy under Python earlier, and on that stack this is faily easy to set up. I typ...
c# entity-framework-core logging unit-testing xunit
asked by codeape

Page 1 of 3
  • 1
  • 2
  • 3
  • ยป

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!