We have recently started using Daper with EF Core. Our unit tests are written based on previous implementation of EF Core and using default SQLLite.
Now we want to test our repository and dependent unit tests but it gives error like Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'no such table: public.MyTables.
I have reviewed daper documentation and there are no details on unit testing and also checked the DaperDemo. https://github.com/abpframework/abp-samples/tree/master/Dapper/DapperDemo
Please can you help with a sample on how to unit tests code or repository that using daper. Thanks
-
ABP Framework version: v8.3.0
-
UI Type: Angular
-
Database System: EF Core (PostgreSQL) and Daper
-
Tiered (for MVC) or Auth Server Separated (for Angular): yes
-
Exception message and full stack trace: No Such Table found
-
Steps to reproduce the issue:
Write unit test that calls the Daper repository to access seeded data.
1 Answer(s)
-
0
Unit tests are configured to execute all the migrations and data seeds initially by default.
Do you have required migrations for your custom tables in the project?
Even you don't use EF query, you can still add your custom tables to the DbContext and create migrations to apply database scheme to the database. This is the easiest way to create tables in the test environment.
Otherwise, you can customize your test module and add custom sceheme migration logic in the
OnApplicationInitialization
method.