No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’ – MVC5

Hey everyone,

Just an error I came across while trying to use a new solution project:

No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’

The fix for this was simply to run the following command in the package manager console:

1
PM> Install-Package EntityFramework

Thanks to StackOverflow for the details: http://stackoverflow.com/a/18642452/522859

Change Default MVC5 Password Complexity Requirements – Passwords must have at least one non letter or digit character. Passwords must have at least one digit (’0′-’9′). Passwords must have at least one uppercase (‘A’-’Z’)

Hey everyone,

I’ve started on a new MVC5 project and came across the following error message while trying to register a new user:

Passwords must have at least one non letter or digit character.
Passwords must have at least one digit (’0′-’9′).
Passwords must have at least one uppercase (‘A’-’Z’)

While having a secure password is obviously important, I felt that most users would probably find these requirements a little extreme. After a bit of Googling I came across a StackOverflow post that mentioned a config class that you can use to edit these settings:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// App_Start > IdentityConfig.cs
 
...
 
// Configure validation logic for usernames
            manager.UserValidator = new UserValidator<ApplicationUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit = true,
                RequireLowercase = true,
                RequireUppercase = true,
            };
 
...

Unescape String in Watch Window – Visual Studio

Hey everyone,

Just a quick post on how to remove the escape characters from a string in the watch window. All you’ve got to do is append “,nq” (short for no quotes) to the watch variable name.

1
MyLongString becomes MyLongString,nq

This removes all of the quotes and line breaks. Pretty handy for when you’ve got to copy the values.

Check out these links for more info:

MSDN: http://msdn.microsoft.com/en-us/library/e514eeby%28v=vs.100%29.aspx
StackOverflow: http://stackoverflow.com/a/9786653/522859

How to Open the Same File Twice in Visual Studio

Hey everyone,

Today I was working on a fairly large class and needed to compare two different areas of code. I’m used to using text editors such as notepad++ and sublime where I would normally just open the file multiple times. It turns out that Visual Studio has a similar feature, although it’s admittedly a lot less intuitive:

- Open the file you want to duplicate and make it the active tab (just click on it somewhere)
- Select window from the menu up the top
- Click New Window

This will duplicate your active tab. To place them side by side simply right click on one of them and then select ‘New Vertical Tab Group’.

Thanks to this Stackoverflow post for the solution: http://stackoverflow.com/a/772159/522859

View Generated SQL in Entity Framework (EF)

Hey everyone,

Just a quick post on how to view the generated sql in entity framework. To start with, just add the following line to your db context constructor:

public class TestDbContext : DbContext
    {
        public TestDbContext() : base("name=TestDbContext")
        {
            this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); //This line
        }
        ...

With this line added, you should now be able to see all of your generated sql in the output window.

SELECT TOP (1) 
    [Project1].[VidId] AS [VidId], 
    [Project1].[CreatedAt] AS [CreatedAt], 
    [Project1].[CHECK] AS [CHECK], 
    [Project1].[SourceCheck] AS [SourceCheck]
    FROM ( SELECT 
        [Extent1].[VidId] AS [VidId], 
        [Extent1].[CreatedAt] AS [CreatedAt], 
        [Extent1].[CHECK] AS [CHECK], 
        [Extent1].[SourceCheck] AS [SourceCheck]
        FROM [dbo].[Vids] AS [Extent1]
        WHERE [Extent1].[VidId] < @p__linq__0
    )  AS [Project1]
    ORDER BY [Project1].[VidId] DESC
 
-- p__linq__0: '535' (Type = Int32)
-- Executing at 28/06/2014 5:00:16 PM +10:00
-- Completed in 0 ms with result: SqlDataReader

If you’re not using EF6, there were a few other options where I came across this solution: http://stackoverflow.com/a/20751723/522859

Dragging a File from File Explorer Causes Google Chrome to Crash

Hey everyone,

A team member found an interesting bug today that caused chrome to go non-responsive. The cause was simply dragging a file from the file explorer onto a drag and drop upload area. It is reproducible on every site I’ve tested, including Gmail and Dropbox.

Reproduce

  • Go to https://mail.google.com
  • Click compose
  • Click attach files (close any of the annoying popups that appear)
  • DRAG a number of files from the file selector window to the new message screen (they will start to upload) (IMPORTANT: these need to be dragged from the file selector popup, NOT a new explorer window)
  • While they are still uploading hit cancel on the file browser window. Browser will go non-responsive

A bug has been reported here: https://code.google.com/p/chromium/issues/detail?id=388661

How to Open the Same File Twice in Visual Studio

Hey everyone,

I was working on a fairly large class in visual studio and having a bit of trouble comparing two different areas within it. Thankfully, StackOverflow knew of a way to make things a lot easier – open the same file twice:

- With the tab you want to duplicate currently active, select Window from the menu
- Click new window
- On the new window, right click and select ‘New Vertical Tab Group’ from the drop down

How to stop text taking up more than one line – CSS

Hey everyone,

Just a quick post on how to stop text taking up more than one line using only CSS:

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

You can check it out using this fiddle: http://jsfiddle.net/wb5m7/
There’s also a great StackOverflow post: http://stackoverflow.com/a/572302/522859

Duplicate type name within an assembly. – Entity FrameWork (EF)

Hey everyone,

I ran into this error message while trying to debug a project today:

“Duplicate type name within an assembly.”

 

The workaround to this was actually pretty weird. Remove all of your breakpoints that appear before this exception and place one after it instead. That’s it!

A bit of a weird issue, but according to the StackOverflow post where I found the solution Microsoft are aware of it: http://stackoverflow.com/a/23529882/522859

Twitter Authentication 401 Unauthorized – MVC4/5

Hey everyone,

Just testing out twitter authentication and ran into the following error:

Response Status code does not indicate success: 401 (Unauthorized).

To fix this, all you’ve got to do is go to you Twitter App settings and:
- Add a callback url (doesn’t have to be real)
- Check the ExternalLoginConfirmationViewModel checkbox