1

I am using ASP.Net MVC5 and Entity Framework with code-first migrations.

During the Seed method for my migration Configuration class, I want to access a read from a data file I have in my project. How can I specify the path so that it will be found both in development and deployment?

The following does not work (of course).

    protected override void Seed(ApplicationDbContext context)
    {
         BinaryFormatter serializer = new BinaryFormatter();
         using (Stream binaryStream = File.OpenRead("Data/seed.bin"))
         {
            ...
         }
        context.SaveChanges();
    }
Toby Sharp
  • 2,029
  • 3
  • 19
  • 21

0 Answers0