Comments (4)
Two things that I didn't grok at first:
- Keep DbContext's isolated; don't re-use the same context to seed the database and then query.
- Call
EnsureDeleted
after each test
Another minor gotcha for me: Call EnsureDeleted
before calling Assert
(in xUnit), so if the assertion fails, you aren't left with stuff in the DB.
from entityframework.docs.
If you're talking about testing that hits the database, then be sure to call it something other than unit testing. But yes, having an article on integration testing between EF and the database would be great!
from entityframework.docs.
We already have #95 tracking this - EnsureDeleted is actually probably not the best as it will cause issues with multi-threaded testing. #95 has details on how to get a database scoped to each test.
from entityframework.docs.
@ardalis: I actually meant using the InMemory provider to unit test other code that calls into EF.
@rowanmiller: Thanks!
from entityframework.docs.
Related Issues (20)
- Document ListValueComparer breaking change
- Document MsBuild integration
- Documentation improvement about data-seeding
- Concerning DbContext disposal HOT 1
- missing defaults information HOT 1
- I cant make use of the Entity.FrameworkCore HOT 1
- Missing doc about Primitive Collections HOT 1
- Doc does not address the most common use-case, when DbContext is injected
- Entity Framework Core 9 HOT 2
- AddRange & Internal Snapshot Method Missing Info
- Primitive Collection Must Implement IList
- Please provide some code samples how to use it in reality. HOT 1
- include
- NoTracking and NoTrackingWithIdentityResolution have the same description. HOT 1
- Numeric rowversions doesn't need a HasConversion call HOT 1
- Document materialization interceptors are singleton HOT 1
- Migrations HOT 1
- Missing information on setting clustering with attributes
- document results for "undefined behavior" queries, e.g. Min/Max on an empty collection, StartsWith(null), etc
- EntityTypeAttributeConventionBase disappeared HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframework.docs.