Category: Development

Visual Studio Data Tools Schema Compare does not work against Basic edition SQL Azure databases

Before you spend any time banging your head against the wall on this, please note that SQL Data Tools schema comparisons do not work against SQL Azure Basic databases. It will fail with some kind of timeout error. Do not be tempted to start messing with your default SQL timeouts. The default is already 60 seconds and thats plenty of time for almost everything you will encounter.

To change your edition (and there are many reasons to, not least point in time continuous backups and geo replication), you will need to go to the Scale tab on your database and select at least a Standard subscription type.

 

Azure Mobile Services prompt for login when clicking on ‘try it out’

Could not work out how what to do about this, but found this solution (http://blogs.msdn.com/b/musings_on_alm_and_software_development_processes/archive/2014/10/23/azure-mobile-services-prompts-you-for-a-username-and-password.aspx).

Use one of your access keys in the password field, leaving the username blank.

Then you can browse to the /help url for your mobile service.

Getting access to and using Visual Studio code snippets with Resharper installed

When you first install Resharper, your Visual Studio code snippets are imported into Resharpers ‘Live Templates’. This is all very well until you install, update or create new Visual Studio code snippets.

If you have ever wondered how to use the Visual Studio code snippets when you have Resharper installed then here is the quick solution.

Press CTRL+J and then start typing the code snippet shortcut you are after. You will now see the list of available Visual Studio code snippets.

You can find this mentioned here http://www.jetbrains.com/resharper/webhelp/Templates__Applying_Templates__Inserting_Imported_Code_Snippets.html

Proud to be Xamarin Certified

After looking at all the various methods and frameworks for cross-platform mobile development, I decided that Xamarin‘s approach and mature tech was the way to go.

I got a subscription and signed up for the Xamarin University training course. Many late nights doing excellent live training, a visit to the Xamarin Evolve 2014 conference in Atlanta and a tough 150 question 3 hour exam later…I am now officially a ‘Certified Xamarin Mobile Developer’

Oh…and it was not easy! 1 minute 12 secs per question and an 80% pass mark!!

 

Xamarin certification can be verified at https://university.xamarin.com/certification#verify and found in the Xamarin Certified Developers LinkedIn Group.

If you are wanting or thinking of developing mobile apps, then this is a brilliant technology for managing the whole process. Code shared across platforms can be as high as 95% when using Xamarin Forms. And it creates native apps…not horrid HTML/JavaScript things!

Entity Framework – Setting integer keys client side gets ‘Cannot insert the value NULL’

I have just been banging my head against a wall trying to get a simple database record added to a simple table using Entity Framework! My table has a primary key field of type INT, but is NOT set as an identity field (i.e. Not set to increment SQL server side). I wanted the ability to set the Id in code.

An example would be a model like:

public Contact
{
    [Key]
    public int Id { get; set; }
    public string Name { get; set; }
}

then you would normally expect the standard EF code like this to work

var myNewContact = new Contact
{
    Id = 123,
    Name = "John Smith"
}
DataContext.Contacts.Add(myNewContact);
DataContext.SaveChanges();

However it always came back with the a DbUpdateException stating

“Cannot insert the value NULL into column ‘Id’, table ‘MyDatabase.dbo.Contacts’; column does not allow nulls. INSERT fails.”

It turns out that Entity Framework assumes that an integer [Key] field will always be generated server side. Maybe I should have known this, but actually found it very hard to locate this bit of information.

Once you know this the fix is very straight forward. You just need to decorate your model object with

[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]

so the model above becomes:

public Contact
{
    [Key, DatabaseGenerated( DatabaseGeneratedOption.None )]
    public int Id { get; set; }
    public string Name { get; set; }
}

I hope this saves someone wasting as much time and loosing as much hair as I did on this simple issue!

One reason it took so long, is that I can’t get Entity Framework Profiler working with the Azure Emulator. If any has had any success with this, please let me know.

HTML emails and getting all you styles in-line with a free online tool

If you have had to put together any html email templates then you know what a pain it is getting things right for all the various email clients out there. especially as Google’s Gmail has a nasty habit of stripping all the CSS goodness from html emails leaving them look not how you intended.

The best advice is to make sure all your styling is inline. This can be a pain to manage if you need to design multiple templates. Thanks to a very neat facility provided by the team at Campaign Monitor you can design your emails using good CSS principle using styles and classes.

When you want to make the final HTML with all your styles in-line, use the free online ‘CSS Inliner’ tool by Campaign Monitor at http://inliner.cm/