Introducing FOREIGN KEY constraint '' on table '' may cause cycles or multiple cascade paths

Today, when I was working with the Entity Framework I got a really annoying error: Introducing FOREIGN KEY constraint '' on table '' may cause cycles or multiple cascade paths I discovered several ways of getting rid of this exception. The fastest of which was:

As I am building only a prototype: data integration...

Returning HttpError Response in WCF

Today I had to throw an HttpException but it turned out the on the WCF side this only returns Error 500. Whenever you throw a HTTPException you need to catch it in your service:

Adding Basic Authentication to WebRequest

In order to add a basic authentication to your HttpRequest you do this:

In basic authentication you need to use Base64 to encode the credentials.

Extract Username and Password from Basic Authentication

This will explain in detail how this all works: Step 1 - Understanding Basic Authentication Whenever you use Basic Authentication a header is added to HTTP Request and it will look similar to this: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== http://en.wikipedia.org/wiki/Basic_access_authentication "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" is just "username:password" encoded in Base64 (http://en.wikipedia.org/wiki/Base64). In order to access headers and other HTTP properties...

Populating Database with Random Data

Generating large set of data can be potentially problematic. The prototype I am currently working on needs to presentable, so putting names like "ASDF" makes no sense and doesn't look particularly good.   I used: http://listofrandomnames.com/ to populate my database with random names. Below you will find some C# ready code if you want to use...

Invalid Cast Exception with Nested Master Pages

System.InvalidCastException is apparently quite a common error in Nested Master Pages. Quite frankly, the problem seems to be completely random:

I solved my particular problem by adding batch="false" to the compilation tag:

This has some implication on performence and you can read more about it here. Update: 2 weeks later I was still...

Automated WCF RESTful System Testing with VS

I discovered a bit of a hack for automatically system test WCF services just using unit tests. Although, this is not the best testing practice, it does allow to quickly verify the behaviour of the service under several circumstances which are not easily 'testable' with simple unit tests e.g. authorized/unauthorized. Unfortunately, VS doesn't allow to...

Accessing DbContext From a Different Project

Today, I discovered in interesting pitfall when accessing the database from different projects (inside one solution). I have defined connectionString in the Web.config file. To my dismay, this was not sufficient if you want to use your data context in different projects. Specifically, I was greeted by "Connection could not be opened" error. The inner...

ASP.NET Submit button not working (unresponsive)

ASP.NET Forms are a thing of the past... Or are they? Well... I was trying in all my power to do a cross-site data submit. Interestingly enough, the button simply didn't work. Literally, You click it and nothing happens. I did manage to fix it. How?

I removed and that fixed it.