Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Thursday, October 16, 2014

Project: No easy way to change class names using EF or MVC

I am still testing around the MVC and EF tools. What I have been trying is to change a class name. Although this probably happen very rarely, this exercise at least helped me understand how some of the pieces fit together.

It was interesting that the cshtml are not included in the global name change updates. I had to manually go through each one to update to the new class name. I also noticed that all the model parameters always have the red squiggly underline. This does not have an impact as I was able to eventually get the site running again.

Clearly, this is an example that is kind of the drawback to scaffolding (sorry, still not completely familiar with the term yet). Because a lot of the code is generated based on the class name and because they are internal variables, these variable names do not change. This is not a major problem for the code as it will still render but will be just as misleading as they would still reference the old class name. This also includes the documentation. The best way is probably use the Visual Studio's CTRL+ALT+F feature to just replace all terms. Hopefully, the term is not too simplistic to impact other variables.

Somehow my table name was updated with the new model name. I am not exactly sure how I did this or when it happened as I was not checking that while I was correcting the files. I did run an Update-Database. This is my best guess on when it possibly could have occurred. Later, I did an Add-Migration and Update-Database. But because the Up/Down methods were empty, I assumed there were no changes.

At then end of the day, it is possible. I'm not sure how complex some of these classes may become, but with simple classes, it is much easier just to recreate a new class. I'm sure there probably is a way to delete the old tables. Hopefully, you just never have to make these changes.

Project: EF6, Resetting Entity Framework (VS 2013 Express, SQL Server Express, C#)

This was my first time working with Entity Framework. Because I used it in a web application, I had to fidget with some of the instructions I found online that worked with a console application. Somewhere in the middle of the setup, I changed the database and I think this is where I must have broken something.

Basically, I followed the initial setup so I had a migration for Initial Create. In this setup, I had created a class. In this area, I am not sure exactly how to replicate what I ended up with. Somehow I ended up with the migration scripts for creating the initial ASPNET tables but not my class (MyForm).

I continued to use add-migration with no luck. It will not attempt to create the table. The up/down methods are always empty. I am not exactly sure where it stores the information that it has already attempted to generate MyForm. I looked inside the script for InitiateCreate but I do not see the class or table in there.

Next I tried to make a modification, and this did generate an add column. Because I do not have the table, this update failed. Just to test it further, I also created another class. This also generated scripts for creating a table. Of course this failed, because the other update to add column is still pending.

After several more hours of banging my head, I finally decided to start over. This posed another set of problems. I quickly found this link which gave me the command (Update-Database -TargetMigration:0).

When I tried to add-migration again, I get the error that I still had pending migrations. I tried to look everywhere on how the system knows that I still had pending migrations. I just took a risk and just deleted the migration files in the Migrations folder. Initially, I had moved them to a backup folder but of course the project would still find it since it is in the same namespace. I guess I could have just dropped them from the project. Fortunately, by running add-migration, I was able to recreate the Initial Create scripts again.

Also another problem with the tutorials were that they were all using Visual Studio 2012 or 2010, while I am using 2013 Express. Some of the layouts and forms were slightly different. Because my problem was a bit unique, these slight differences really made me question a lot more than I should have. It would be nice if there were tutorials on how to make a blanket rollback without restarting a new project.

Error Messages


  • "Unable to generate an explicit migration because the following explicit migrations are pending"
  • object does not exist

Reference

http://stackoverflow.com/questions/10282532/entity-framework-start-over-undo-rollback-all-migrations

Monday, January 6, 2014

Project: My First Attempt in Doing Anything in Linux

I thought that I was quite flexible in understanding how to run computers. I have quite some experience supporting Windows systems for personal and business use (albeit enterprise level). Yet, I cannot naturally navigate and figure things out on Linux. I would imagine switching from Linux to Windows is much simpler than Windows to Linux.

From installing applications, installing drivers, finding upgrades, to just basic command prompt uses, I have struggled with them all. By struggle, I mean that I had to either web search or read a book. Nothing seemed intuitive to me... or perhaps this is a sign of my age. Even following instructions was not always so simple. There was always something different, especially in the GUI. Command prompt was more similar between versions and distributions, but it does not always play very nicely with other components that were installed through the GUI.

In my opinion, the GUI should be simple to use but I have actually found that the command prompt has comparable perks (or rather fewer 'issues'). There are also some nuisances in the GUI that does not quite allow you to just use the keyboard without having to switch to the mouse.

After this experience, I can see clearer on how Windows can still be quite powerful yet having always many IT professionals complaining about them. Windows requires much less knowledge about the system to get a development environment running or even just simple infrastructure use. I can simply install Windows, Visual Studio, and MS SQL Server and have a development environment basically ready for me to develop. A little bit of knowledge on public IP address and you can publish a simple web application within a day or two.

I have already spent over a week just trying to get Linux running with Python, Eclipse, and Django. Along with the installation, I have also learned a lot of other functions to running and maintaining Linux that I would not care much for as a developer. So although Linux may be more enterprise friendly, it is not so friendly on the individual level. I would think just to get a company started with Linux technology, you'll need at least 2-3 people at the minimum for average entrepreneurs: someone that understands how to maintain Linux, a developer, and sales. While for Windows, you really only need one person because a sales person could throw together a web application... maybe two where the developer also maintains the server. Sure you could find a Linux person who can do all three, but from my experience, they are far from being sales people even if they have superior products while sales people could sell Microsoft inferior products.

I've heard some friends say that Linux is still dominant in enterprise level but I see more and more conversions to .NET solutions on enterprise websites. This may not be an indication that they Microsoft-centric for their infrastructure, but by their hype I would imagine that the technology should be changing in the direction of Linux as companies grow to enterprise level. They also say it is free, but Microsoft's solution is basically free too (only because everyone practically already has it). You can find companies with only Microsoft products, but you will be hard-pressed to find companies with absolutely zero Microsoft systems.

Although this is mostly my rant on the learning curve to Linux, I am not bashing on its power and effectiveness technologically. I just think if the community did a better job on making it more newbie-friendly, they may find that they would have a greater impact... but then with some Linux folks, they almost seem like they design Linux just to prevent technology illiterates from converting.


Reference

http://askubuntu.com/questions/224942/linux-headers-not-upgraded

Project: Sometimes Things Just Break

Sometimes the world throws you lemons, you try to make lemonade, but you find they already rotted.

My friend had an extra system but missing hard drive. Later he found an extra hard drive. I tried to install Windows which was going fine until there was some corruption in the MBR thus making it inoperable. I tried to play around with this to find a way around it but to no avail.

Then we tried another hard drive. I was able to install Windows XP and a few other apps. Then this morning it fails to even power up. I think the power supply broke down.

Although not major losses, I cannot help but feel that there is something in the world that just likes to clump misfortune into a short period of time. But I am still ok and still moving forward with my Ubuntu project. I will start tagging the posts as 'project' instead of 'Ubuntu' because the things I am starting to work on are not really related to Ubuntu but still want to reference them all together.