public class OutageInitializer : DropCreateDatabaseIfModelChanges<OutageDBContext>
{
protected override void Seed(OutageDBContext context)
{
var outages = new List<Outage> {
new Outage { Title = "Scheduled Maintenance",
PostedOn=DateTime.Parse("2012-5-4"),
CompletedBy=DateTime.Parse("2012-5-4"),
Details="The system is currently offline whilst we perform some scheduled maintenance tasks. We expect the work to take no more than 2 hours. Please try back after 10:00 AM."}
};
outages.ForEach(d => context.Outages.Add(d));
}
}
I copied the connection string from the connection string in the image above (I then redid the image above to make sure the copied web config pulled that through.
The database and webservers are local, we don't use hosted we have everything in house.
I can access the database and the default line I have added is visible:
EDIT:
I have also deleted the autoscripts and used data and schema, this populated the line seen above in the database, but it is still the same when I go to the site.
Edit:
In terms of the connection string I tested through excel (I know probably not the best but it gives me a connection string) and this is what it gives me:
Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=user name;Data Source=server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=computer;Use Encryption for Data=False;Tag with column collation when possible=False;Initial
Catalog=Outages
Does this look better and if so do I need to just exclude the workstation ID or is there any thing else that will need adding/ removing? Also does this need to go in the release web.config only or the main web.config and the publish sql tabs connection string
as well? Did I need to keep the default connection string as well ? When I tried to deploy that as well I got a table exists error for the meta data table.
mcinnes01
Member
16 Points
121 Posts
Re: Help deploying code first website with database
May 04, 2012 09:38 AM|LINK
public class OutageInitializer : DropCreateDatabaseIfModelChanges<OutageDBContext> { protected override void Seed(OutageDBContext context) { var outages = new List<Outage> { new Outage { Title = "Scheduled Maintenance", PostedOn=DateTime.Parse("2012-5-4"), CompletedBy=DateTime.Parse("2012-5-4"), Details="The system is currently offline whilst we perform some scheduled maintenance tasks. We expect the work to take no more than 2 hours. Please try back after 10:00 AM."} }; outages.ForEach(d => context.Outages.Add(d)); } }I copied the connection string from the connection string in the image above (I then redid the image above to make sure the copied web config pulled that through.
The database and webservers are local, we don't use hosted we have everything in house.
I can access the database and the default line I have added is visible:
EDIT:
I have also deleted the autoscripts and used data and schema, this populated the line seen above in the database, but it is still the same when I go to the site.
Edit:
In terms of the connection string I tested through excel (I know probably not the best but it gives me a connection string) and this is what it gives me:
Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=user name;Data Source=server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=computer;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=Outages
Does this look better and if so do I need to just exclude the workstation ID or is there any thing else that will need adding/ removing? Also does this need to go in the release web.config only or the main web.config and the publish sql tabs connection string as well? Did I need to keep the default connection string as well ? When I tried to deploy that as well I got a table exists error for the meta data table.