Every now and then I have to restore or copy a database. Depending of the edition of SQL Server it is not always possible to use the copy database function. You have to do backup and restore database. Very often I get error message in the restore saying something like «sql 2012 cannot be overwritten. Is is beeing used by database«.  This happens because I always have created an empty database to restore to, but you don’t actually have to create an empty database first. It is possible to restore a database by right-clicking on the root folder «Databases» and run «Restore database…». The database is beeing created as you restore your database.

Advertisements

Enable migrations of database using code first modeling

I’m quite new on developing MVC applications, but I find it very interesting. However it is quite different from developing traditional web form applications. One of the first most important tasks you have to do is to model your application.

In MVC applications you use Entity Framework to integrate with your database. You got three options when you shall model your database. This is:

Database first

Code first

Model first

When you have worked with your model for a while you might need to update your model and database.

Here’s how you proceed when you want to update your database:

– If you haven’t done it already you need to install Entity Framewirk nuget package (Install-Package EntityFramework)

– Run Enable-Migrations -ContextTypeName [YourApplicationName].Models.[DatabaseContextName] [optional : -Force]

 

Troubleshooting

If there are inconsitencies between database and model in your application, you should delete the table Migrations from database and the folder «Migrations» from your web application and then run:

Enable-Migrations -ContextTypeName [ApplicationName].Models.[DbContextTypeName] -EnableAutomaticMigrations -Force

Then you have to run:

update-database -verbose -Force

to in order to update database.

Reference

http://msdn.microsoft.com/en-us/data/jj591621.aspx

Sjekkliste ved bruktbilkjøp

I dag så jeg to nyttig sjekklister ved kjøp av bruktbil. Sjekklisten er laget av Bjørn L. – sjef for NAF. Sjekklisten er publisert i Østlandets blad.

Kilde: Øslandets blad – torsdag 11.oktober

Sjekkliste ved prøvekjøring av bruktbil

I dag så jeg to sjekklister i den lokale avisen på Ski (Østlandets blad) av NAF sjef Bjørn L.

Her er en sjekkliste for hva man skal se etter når man prøvekjører en bruktbil:

  • Syns- og funksjonskontroll
  • Lakk-, rust- eller  kollisjonsskader?
  • Er bilen tidligere skadet?
  • Se etter rustskader på innerskjermer, underside på dører, skjermbuer bak koffertlokk/bakluke
  • Er frontruten uten steinsprut og riper?
  • Er glass og reflektorer på hovedlys, blinklys og baklys i orden? Fungerer alle lys innvendig og utvendig?
  • Kan dører, panser og koffertlokk lett åpnes lukkes?
  • Fungerer alle låser og vindusheiser?
  • Se og kjenn etter fuktighet innvendig i bilen, under matter og i koffertrom
  • Kontroller dekkene også de som følger med. Vær spesielt oppmerksom på skjevslitte dekk
  • Kontroller motoren for olje- lekkasje og kjølevannlekkasje. Se også etter lekkasje fra drivstoffsystem.
  • Er bilens batteri godt montert og rent?
  • Finnes verktøy, reservehjul, jekk, varseltrekant, nøkkel til låse-hjulbolt, instruksjonsbok.

Se også:

http://www.naf.no/Alle-saker/NAF-eksperten/Kjop-og-salg/Sjekkliste-ved-kjop-av-bil/

Kilde: Østlandets blad torsdag 11. oktober

Environment variables in Windows

Variable Typical value (May vary, depending on system)
%ALLUSERSPROFILE% C:\Documents and Settings\All Users
%APPDATA% C:\Documents and Settings\{username}\Application Data
%COMPUTERNAME% {computername}
%COMSPEC% C:\Windows\System32\cmd.exe
%HOMEDRIVE% C:
%HOMEPATH% \Documents and Settings\{username}
%PATH% C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem
%PATHEXT% .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH
%PROGRAMFILES% Directory containing program files, usually C:\Program Files
%PROMPT% Code for current command prompt format. Code is usually $P$G
%SYSTEMDRIVE% The drive containing the Windows XP root directory, usually C:
%SYSTEMROOT% The Windows XP root directory, usually C:\Windows
%TEMP% and %TMP% C:\DOCUME~1\{username}\LOCALS~1\Temp
%USERNAME% {username}
%USERPROFILE% C:\Documents and Settings\{username}
%WINDIR% C:\Windows

Referanse

http://vlaurie.com/computers2/Articles/environment.htm

Web.config – IIS7 – FW4

This blogpost is a reference for myself so I’m able to remember what is important when configuring web.config for a MS Framework 4 web appliction on IIS 7.x.

When configuring a web application it is often easy to forget details for making the web application work smoothly.

Here are some reminders when configuring web.config:

  • The compilation tag must contain the attribute targetFramework=»4.0″
  • System.web tags must be renamed to system.webserver on IIS7.x
  • Httphandlers are called handlers on IIS7.x
  • Httpmodules are called modules on IIS7.x
  • If «system.codedom» exists in web.config, remove all content for Framework 4

Further update is coming later…

URL Tools

This blogpost has it’s purpose to be an explanation to my self in order to understand and remember what I have previously researched on.

URL is a word often used on hyperlinks used on internet. Url which is a acronym for uniform resource locator.

Explanation of Uri, Url, Urn and Urc
Ifølge W3C så er alle hyperlinker URIer (uniform resource idenfier). Innen for begrepet URI har vi fins det to typer.
URL (uniform resource locator) er en type URI som lokaliserer en ressurs mens urn viser til navnet på en ressurs

According to W3C all kinds of links are URI (uniform resource identifier). There are two types of URIs called Url and Urn. Additionally there are another acronym called Urc. In short the three acronyms can be explained like this:

URL (uniform resource locator) is a address that referes to the location of a resource.

URN (uniform resource name) is the name of a resource regardless of the location.

URC (uniform resource characteristics/citation) is often used when talking about metadata like author, copyright for a resource.
Shorten urls

Tinyurl
This is a website tool that help with shorten long hyperlinks. The new link always starts with http://tinyurl.com and then a cryptic word what idenifies your site. Instead of the cryptic word you may specify your own word that will identify your resource.

goo.gl
Similar to Tinyurl. This is a tool provided by google. If you insert the character plus (+) at the end of your url you get statistics and more information regarding your site. Pretty neat! 🙂

https://bitly.com/
Similar to goo.gl. Provides information similar to goo.gl by putting the character plus (+) at the end of the link.

http://is.gd/

Similar to goo.gl and bit.ly, but you need to provide the character minus (-) in order to get more information about the link.

To avoid phishing, malware, and viruses there are pages that gives you the opertunity to check the url before you navigate to it. You can use http://LongURL.org to check the real address for the resource you will navigate to.

Storing favorite links

http://delicious.com/

Entertainment

http://break.com

http://www.stumbleupon.com/

To be continued later…

Referanse: