Possible Duplicate:
sqlbulkcopy using sql CE
I am trying to insert a lot of data from C# into a SQL Server CE database. Currently I am working with Entity Framework, pocos and poco-configuration classes because the property names of the pocos does not match the column names in the database.
I've already read a lot of articles and blog posts about this topic but no one of them matches exactly my problem with server generated id's and foreign keys.
public class Country
{
public int Id { get; set; }
public string Name { get; set; }
}
public class City
{
public int Id { get; set; }
public string ZipCode { get; set; }
public string Name { get; set; }
//Foreign Keys
public int CountryId { get; set; }
}
public class Address
{
public int Id { get; set; }
public string Name { get; set; }
public string Number { get; set; }
//Foreign Keys
public int CityId { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string SecondName { get; set; }
//Foreign Keys
public int AddressId { get; set; }
}
public class EmailAddress
{
public int Id { get; set; }
public string Email { get; set; }
//Foreign Keys
public int CustomerId { get; set; }
}
That are my pocos and the IDs are server generated. So what is the fastest way of inserting a lot of Customers
with Addresses
and EmailAddresses
into a SQL Server CE database.