morrisjdev / FileContextCore

FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Apache License 2.0
169 stars 45 forks source link

No opportunity to set file name or relative path in database #19

Closed superarchi closed 4 years ago

superarchi commented 4 years ago

I already have some folders structure with CSV files. And I want to map it to DbContext. How can do it?

This example not works now:

[Table("Users\\User")]
public class User : Base
{
}
morrisjdev commented 4 years ago

Hi. Sorry for the late reply.

Somehow it is not possible to define a custom table name this way in EF Core 3.0.0. Maybe its a bug and will be (or is) fixed in future releases.

You can define a custom table name using the fluent API. Add this to your context class:

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>()
                .ToTable("custom_user_table");
        }

I also made a small change in the code to also support defining custom sub folders. This will be published in the next release. Until now you can only use a flat folder with all files but you can define a custom file name.