1

I have an Entity Framework model automatically generated from the database. The database has been changed to varbinary(max) for SessionValue column. The model use to look like this:

public partial class Session
{
    public int SessionID { get; set; }
    public string SessionKey { get; set; }
    public string SessionValue { get; set; }
    public System.DateTime SessionExpiryDate { get; set; }
}

I manually changed it in the partial file to look like this:

public partial class Session
{
    public int SessionID { get; set; }
    public string SessionKey { get; set; }
    public byte[] SessionValue { get; set; }
    public System.DateTime SessionExpiryDate { get; set; }
}

So basically I changed SessionValue from a String to a Byte Array. Now when I run my MVC.NET app, it doesn't start up, it gives this error:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

If I undo my change, all is well again. How do I go about debugging this? It's not even hitting any events in Global.asax. It feels as though Entity Framework should automatically do some work in the background - but doesn't because the Model properties view doesn't allow me to map it to a Type byte[].

Someone please help!

c0D3l0g1c
  • 3,020
  • 5
  • 33
  • 71
  • I'm not sure about wich MVC version you are using, but I'd try changing the class name to AppSession just to see this class is not interfering with the old Session class in previous MVC versions. – Mauricio Atanache Mar 22 '19 at 15:53
  • Nope... that's not the issue. I changed the class name and some property names from the real object. – c0D3l0g1c Mar 22 '19 at 15:59
  • Have you tried changing the property in the EDMX instead of directly in the generated class? – Lews Therin Mar 22 '19 at 16:16
  • I can't change in EDMX file because byte[] isn't listed as an option. That's why I manually changed the partial class. If this is possible and you know how to, please explain. Thanks! – c0D3l0g1c Mar 22 '19 at 16:30

1 Answers1

0

Found the answer here: EntityFramework database first - type mapping - map binary(8) from SQL to int in C#

Need to set the Type on the Model Property to Binary - I was looking for byte[]. That's a proper gotcha! After this change, updated the model and it's working well. Finally!

c0D3l0g1c
  • 3,020
  • 5
  • 33
  • 71