Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Disabling Proxy Creation
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Titre:
Disabling Proxy Creation
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01605733
Message ID:
01605733
Vues:
34
Update.

By just adding this line

this.Configuration.ProxyCreationEnabled = false;

to the DbContext base class I got the forms to show up.


Hi everybody,

We're in the process of switching to POCO from EDMX. I converted several classes and I am now getting errors from the browser when I try to bring the results. We were able to find out the reason for the errors by making a break point in the service.js file for the page (we're using AngularJs). The error is

Error getting value from 'IInvent' on 'System.Data.Entity.DynamicProxies.IItems_273E69562B3EC494497799CAC1345228EDCEF567C486A08DCDF17F86EA3173DC'."
exceptionType: "Newtonsoft.Json.JsonSerializationException"
innerException: Object
message: "An error has occurred."
stackTrace: " at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
↵ at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
↵ at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
↵ at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
↵ at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract etc.

The object I am trying to bring in is simple but it has reverse navigation properties and it looks like there is a whole long chain of objects, because i_invent table is very deep in hierarchy. It is not related to the particular table (object) I am trying to work with.

So, I read this page about disabling the Proxy and I think it may be worth a shot. http://msdn.microsoft.com/en-us/data/jj592886.aspx

The problem is that our classes are auto-generated. In that tool I see the following in the tt file:
 // v2.6.1
    // Please make changes to the settings below.
    // All you have to do is save this file, and the output file(s) is/are generated. Compiling does not regenerate the file(s).

    // Misc settings **********************************************************************************************************************
    // Namespace = ""; // Override the default namespace here
    DbContextName = "Our Name here";
    ConnectionStringName = "Name here";  // Searches for this connection string in config files listed below
    ConfigurationClassName = "Configuration"; // Configuration, Mapping, Map, etc. This is appended to the Poco class name to configure the mappings.
    ConfigFilenameSearchOrder = new[] { "app.config", "web.config",
etc.
So, I suspect that I should be able to set the setting I need in that Configuration file. There is no Configuration file in the project at the moment. I am wondering if you know how this file is supposed to look like and if you used that tool and the configuration file.

The author of this tool is
// Copyright © Simon Hughes 2012
// v2.6.1
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform