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

DBContext not being populated from CSV files

Oct 14, 2014 at 12:11 AM
Similar to the issue https://effort.codeplex.com/discussions/455481 Effort is creating my dbcontext successfully but none of the tables have any rows in them.

I tried pluralizing the csv files as mentioned in the linked discussion but this did not resolve my issue.

Here's what I'm trying
private ApplicationDbContext effortcontext;
        [TestInitialize]
        public void Initialize()
        {
            IDataLoader loader = new Effort.DataLoaders.CsvDataLoader("D:\\csvs");
            var dataLoader = new CachingDataLoader(loader, false);
            DbConnection connection = Effort.DbConnectionFactory.CreateTransient(dataLoader);
            this.effortcontext = new ApplicationDbContext(connection);
        }
Any ideas?
Oct 14, 2014 at 8:44 AM
Hello,

The CSV file should have exactly the same name as the table in the database. Can you make it work by giving a hard coded name to you table?
Oct 14, 2014 at 5:45 PM
I've tried adding the [Table] data annotation but it didn't help. Is there any sort of logging in Effort that I can follow to see if it's having trouble accessing the CSV files or something of that nature?
Nov 13, 2014 at 9:32 PM
Unfortunately the data loaders do not have logging capabilities.

I put this on my TODO list.
Nov 13, 2014 at 9:59 PM
Do you have any other suggestions for troubleshooting my issue with loading data from CSV files?
Nov 13, 2014 at 10:14 PM
Edited Jan 5, 2015 at 10:45 PM
Unfortunately, I cannot add anything. The names of the files probably differ from the names of the database tables.
Apr 21, 2015 at 7:36 PM
Too late for enturpin but use Process Monitor to find out what files Effort is looking for
May 20, 2015 at 6:37 PM
tamasflamich,

You should put forth some time looking into this issue. At least provide some logging or tracing capabilities.

I've used Process Monitor and I can see the datafiles (csv) being opened and read but my fake DbContext still has no data. The files are correctly named according to my database and it finds them.

The effort library should at least throw an exception when it cannot complete the data load. I'm not even getting that, just that the sequence contains no elements.
Jul 17, 2015 at 1:58 PM
I also have the "the sequence contains no elements" error, with a basic setup :
  • a user class, described in code first :
public class User
    {
        [Key]
        public int Id { get; set; }

        [Required, MaxLength(256)]
        public string FirstName { get; set; }

        [Required, MaxLength(256)]
        public string LastName { get; set; }

        [Required]
        public string Email { get; set; }

        [Column(TypeName = "datetime2")]
        public DateTime CreationDate { get; set; }
    }
  • a two-line CSV to load one row of data :
Id,FirstName,LastName,Email,CreationDate
"1","First","User","first@user.ext","2015-07-01 00:00:00"
I can solve the problem by switching the CreationDate from datetime2 to datetime.
But while using datetime2 column type, no data seems to load in Effort.
And no matter if the date in CSV is written as "2015-07-01 00:00:00", "2015-07-01 00:00:00.000" or even "07/01/2015 00:00:00"

Data are flawlessly saved in DB from a Web Api 2 application.

Hope it helps.
Sep 10, 2015 at 8:24 PM
So, I'm having the same issue. I added [Column(TypeName = "datetime2")] attribute on a DateTime field and now need a workaround for Effort to ignore or work with it, as it is required for the SQL database in production.

Any ideas?