-8

The question was about the concept of database first or code first. When i'm using database first, how i can check if my database is already created and filled.

Thanks

Yassine
  • 331
  • 1
  • 3
  • 9

1 Answers1

2

Really, you are asking two different questions. Entity Framework is not a database administration tool and as such does not have any functionality for directly loading data from a spreadsheet.

If you research each part of your question separately, you might have more luck.

Seeding data with Entity Framework

Reading Excel Files with C#

Reply to comment:

if (!context.PostalCodes.Any())
{
    IEnumerable<PostalCode> postalCodes = ReadPostalCodes();
    foreach(var postalCode in postalCodes)
    {
        context.PostalCodes.Add(postalCode);
    }
    context.SaveChanges();
}
Community
  • 1
  • 1
Tim B
  • 2,340
  • 15
  • 21
  • Sorry :) I have a project with entity framework database First. when i start my application i would like that my application gets , if exist, all postal codes (this part is ok) but if not exist, my application should import all postal codes from a excel file(in my proprety.ressource) to my database. the question is how can i check if my database is created and how can i get data from ressource directory to put them in database? sorry for my english ;) – Yassine Aug 08 '13 at 00:11