Comments (7)
Hi JonPSmith - Sorry for the late response. This shouldn't be a problem as Effort is not able to work when migrations is enabled, the suggested workaround is indeed to disable the initialiser.
What does happen if you indeed initialize your db explicitly?
from entityframework-effort.
Hi @tamasflamich,
The problem is if I call a null initialiser, e.g. Database.SetInitializer<MyDbContext>(null)
then the next time Effort.EF6 accesses the database I get the exception I detailed in the first post above. I do this because some tests do access a real database directly and I want to make sure it doesn't look for migrations.
I have no migrations set on the database so its not that. I'm pretty sure Effort.EF6 doesn't support the calling of a null initialiser.
It would be great to have that fixed, but as a creator of a number of open-source libraries and working I know that time is limited. If you do get a chance to look at this/fix it then let me know.
from entityframework-effort.
@JonPSmith, I had a similar problem. I solved it by registering a System.Data.Entity.NullDatabaseInitializer<T>
in my Dependency Injection container (Ninject, in my case) for production and the default System.Data.Entity.CreateDatabaseIfNotExists<T>
initializer for unit tests. Then in the constructor of my EF context I just select whatever was registered, like so:
Database.SetInitializer(DIContainer.Get<IDatabaseInitializer<MyDbContext>>());
My use case isn't quite the same as yours since I don't have to think about migrations. But, you might consider a CustomInitializer for the tests that does the "Database.CreateIfNotExists()" line recommended in the error message and ignores any migration steps that the default initializer would try to do.
from entityframework-effort.
I'm having a similar issue, except my context is database first but with FluentAPI, so a hybrid model. My Context constructor always runs Database.SetInitializer<Context>(null);
. That being the case, shouldn't Effort also apply this? I've tried putting it in my constructor, as well as in the unit test explicitly, however, I always get
Effort.Exceptions.EffortException: Database has not been initialized.
from entityframework-effort.
Hello @screaney ,
We will try to look at this issue next week,
Best Regards,
Jonathan
from entityframework-effort.
Any news on this?
I'm having the same issue, although calling context.Database.CreateIfNotExists() is not an option for me, because I use a custom initialization infrastructure.
from entityframework-effort.
Hello @michaelfoidl ,
Unfortunately no, we never found a solution.
The Effort
in-memory database doesn't exist by default unlike your real database, so it currently requires the memory database to be created.
from entityframework-effort.
Related Issues (20)
- EffortConnection.RollbackToRestorePoint incorrectly works with identity fields of entities HOT 6
- Target netstandard2.1 HOT 1
- Using multiple EDMX files within a single in-memory connection HOT 4
- In memory db ignores Unique Index HOT 1
- In memory db targeting specific migration HOT 1
- SaveChanges throws exception HOT 4
- FK violation. Value [x] does not exists in the referenced table [t] HOT 1
- How to you create a connection with IdentityDbContext ? HOT 1
- Batch Update is not working with Effort.EF6 HOT 2
- Change Tracking - Single property update of entity seems broken HOT 5
- Exception querying context during unit test HOT 3
- Nested transactions rollback should allow commit on parent transaction. HOT 2
- Z.EntityFramework.Classic.Effort v 2.2.9 is not compatible with NMemory version 3.1.2 HOT 2
- Expose IdentitySpecification so we can change the seed value HOT 3
- Object of type 'a' cannot be converted to type 'b' on Effort.Internal.Common.DatabaseReflectionHelper.InsertEntity HOT 6
- [DatabaseGenerated(DatabaseGeneratedOption.Computed)] Workaround? HOT 10
- Entity Framework Plus - InsertFromQuery command - doesn't wotk HOT 2
- ExecuteSqlCommand can't be used HOT 1
- EffortException when BulkInserting a class with a nullable enum. HOT 6
- Test runs forever without a ToList() on repository query HOT 3
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-effort.