This project has moved and is read-only. For the latest updates, please go here.

DbContext is created but not filled

Sep 4, 2013 at 2:03 PM

I use EntityFramework, TS_ChatEntities is derived from DbContext and have a ctor:
public TS_ChatEntities(DbConnection connection)
            : base(connection, true)
All 3 DB tables are cached with CSV tool in a folder "d:\Temp\11". Then I try:
            var wrappedDataLoader = new CsvDataLoader("d:\\Temp\\11");
            var dataLoader = new CachingDataLoader(wrappedDataLoader, false);
            using (var connection = Effort.DbConnectionFactory.CreateTransient(dataLoader))
                TS_ChatEntities ctxChat = new TS_ChatEntities(connection);
                var ct = ctxChat.Room.Count();
Debug is OK, 'ct' = 0. Though I have 3 records in the corresponding CSV. Then I try to populate Room table with 1 record, DaveChanges and count Room-s again - success (1 record).

VS 2012 reports no error at run-time. How can I find out a reason why EF mock is empty?
Sep 8, 2013 at 6:59 PM
Edited Sep 8, 2013 at 7:01 PM

Unfortunately Effort does not have tracing capabilities that could show more information about this issue. (I added this to my todo list). However my first idea is that your csv files do not have the appropriate name. The csv files has to be named like the corresponding table was named in the database.

For example:

You have an entity named Room. However, by default EF will create a table named Rooms in the database. The data loader only knows about later information, so it will search for a file Rooms.csv
Marked as answer by tamasflamich on 1/25/2014 at 3:16 PM
Sep 10, 2013 at 9:01 AM
Thank you, tamasflamich, pluralizing resolved my issue.