11.29.2012

How to Install Windows Service in Server 2008

1.  Open command as administrator
2.  Go to C:\Windows\Microsoft.NET\Framework64\v2.0.50727
3.  Install service:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727>installutil MyNewService.exe
4.  Go to Services: services.msc in cmd and then start the service.
5.  To uninstall.  First stop the service, then do:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727 installutil /u MyNewService.exe

11.19.2012

Cannot truncate table because it is being referenced by a FOREIGN KEY

This would have the same effect as truncate, minus the warning...(be careful, this also deletes all the data of the table referencing this table)
DELETE FROM dbo.Creators DBCC CHECKIDENT ('dbo.Creators',RESEED, 0)

11.16.2012

Set Up Code First Migrations for EF in ASP.NET MVC 4

First open Package Manager Console: Tools > Library Package Manager > Package Manager Console

1.  Go to the project, either the Web Application or if a separate project for Model, then enable the migration as follows:
PM> Enable-Migrations -ContextTypeName ProductCoC.Model.DataContext
This creates a Migration folder within the project root and creates the initial creation classes as well as the Configuration.cs.  Open Configuration.cs and add your seed.

2.  Initialize
PM> Add-Migration Initial
3.  Now, let's update the database:
PM> update-database
4.  If adding a property to the model classes, change the model class then do an add as follows, any arbitrary name will do:
PM> add-migration AddSoldToPartyAndShipToParty
5.  Now do a database update:
PM> update-database