Tuesday, March 27, 2012

How can I access “Visual Studio Conversion Wizard” for a WebSite?




I'm using this article to convert my ASP.NET 2.0 web application to an ASP.NET 4.0 application.
However, the article states that I will be prompted to change to .NET 4.0 when I open up my project/website.
As I've previously declined this dialog I'm not longer being prompted.
I've read this question which states I should click on the Properties tab of my solution, but I only have "Properties Window". Perhaps this is just for Projects/
How can I get the conversion wizard to reappear for my WebSite was the question of the moment... I looked everywhere and could not find a solution...


Update:


I haven't been able to get the Conversion Wizard to reappear, but I have been able to convert to .NET 4.0 by:
Right Clicking on my website
Selecting Property Pages
Then go to Build tab
Change Target Framework
This made all the changes to my web.config automatically just like the conversion wizard would.


Site seems to be running in 4.0 ...testing time I say.

Friday, March 16, 2012

I hear that breaking things is the best way to learn new concepts.

Anyhu, while working with SQLServerCompact, I had this issue
Could not load file or assembly 'System.Data.SqlServerCe.Entity, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.


I wasnt sure what the issue exactly was and then realized that there was a dependency line in my web.config refereing to this assembly

 
       
       
     

I removed this dependent assembly and my scaffolded control works likea charm now..

MVC 3 Scaffolding


SO I was playing with package manager in MVC and tried to install MVCScaffolding ...

http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/ 

Has all the details I was following to the dot...

kept on getting this error and was very baffled

PM> Scaffold Controller Team
The term ‘Scaffold’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, ver
ify that the path is correct and try again.
At line:1 char:9
+ Scaffold <<<< Controller Team
+ CategoryInfo : ObjectNotFound: (Scaffold:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I managed to solve the problem by uninstalling and reinstalling the MvcScaffolding. That didn’t work at first, but when I uninstalled it using the -RemoveDependencies switch, and then reinstalled it again, everything worked fine again.
So you can try this:
Uninstall-Package MvcScaffolding -RemoveDependencies
Install-Package MvcScaffolding

I was also told that updating the package resolves the issue though am not sure about that...

Here is the code for the bravehearted to try:

1. Enter into your package manager console “Update-Package MvcScaffolding”
2. Then restart Visual Studio

Tuesday, March 13, 2012

Marathon update

Crunch time with my training... here is my updated new and shinny plan




March

Week
Sun
Mon
Tue
Wed
Thu
Fri
Sat
22




1
4m
2
3
15m
23
4

5

6
4m
7
8m
8
4m
9

1020m
24
11

12

13
3,5m
14
8m
15
5m
16

17
12m
25
18

19

20
4m
21
9m
22
5m
23

24
18m
26
25
26
27
5m
28
9m
29
5m
30

31
14m

April


Sun
Mon
Tue
Wed
Thu
Fri
Sat
27
1

2

3
5m
4
10m
5
5m
6

7
20m
28
8

9

10
5m
11
8m
12
4m
13

14
12m
29
15

16

17
4m
18
6m
19
3m
20

21
8m
30
22

23

24
3m
25
4m
26
2m
27

28
Race Day

29
30



 




 So tired and exhausted. Cannot wait till this race is done with...

MVC woes

So, I am diligently working with MVC 3... and ran into a very simple but convoluted problem. I was working with EF "code first" model and modified my model to add some validations...

Guess what ? It stopped running after that. Kept repeating the following message:


The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

Solution:
We need to update the table in Sql Server to have the additional column you added to your entitiy class.

Database.SetInitializer(new DropCreateDatabaseIfModelChanges());

This line is used for in order to allow to edit database by making changes to Model objects.Add this line in Global.asax at Application_Start() method.

Inside the Application_Start method, define the Database initializer with one among the two options.

DropCreateDatabaseAlways: This will drop and recreate the database in every application start.

DropCreateDatabaseIfModelChanges: This will drop and create the database only if the underlined model changes.

Sample code:

protected void Application_Start()
{
Database.SetInitializer(newDropCreateDatabaseIfModelChanges());

AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}

Now it is working perfectly.

Note: DropCreateDatabaseIfModelChanges should only be use early on in development, never on a production machine. If you pushed to a production machine and made schema changes, you'd loose all your data.