dimanche 5 mai 2019

Invalid column name 'TypeName'. Invalid column name 'ETypeId'. Invalid column name 'EventTypeName'

<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for 
content type 'application/xml; charset=utf-8'.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
An error occurred while executing the command definition. See the inner 
exception for details.
</ExceptionMessage>
<ExceptionType>
System.Data.Entity.Core.EntityCommandExecutionException
</ExceptionType>

. . . . Invalid column name 'TypeName'. Invalid column name 'ETypeId'. Invalid column name 'EventTypeName'. System.Data.SqlClient.SqlException at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext1 c) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed) at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

here is the complete exception information, i am sharing link only 
becuase there occurs indentation problem..sorry for disturbance.
[http://localhost:6738/api/ServiceCategories][1]

I  am new to ASP.NET MVC,Code first approach.i am confused with this 
exception.if any body know how to solve this then kindly tell me. i have 
tried to use rational database coloumns in this model but can't have the 
problem solved,  Redundently used columns to solve this but could not do 
so.how to fix it?

public class ServiceCategoriesController : Controller
{
    private ApplicationDbContext db = new ApplicationDbContext();

    // GET: ServiceCategories
    public async Task<ActionResult> Index()
    {
        IEnumerable<ServiceCategory> serviceCategories = null;

        using (var client = new HttpClient())
        {
            client.BaseAddress = new 
            Uri("http://localhost:6738/api/ServiceCategories");
            //HTTP GET
            var responseTask = client.GetAsync("serviceCategories");
            responseTask.Wait();

            var result = responseTask.Result;
            if (result.IsSuccessStatusCode)
            {
                var readTask = await 
                result.Content.ReadAsAsync<IList<ServiceCategory>>();


                serviceCategories = readTask;
            }
            else //web api sent error response 
            {
                //log response status here..

                serviceCategories = Enumerable.Empty<ServiceCategory>();

                ModelState.AddModelError(string.Empty, "Server error. 
                Please contact administrator.");
            }
        }
        return View(serviceCategories);

    }




Aucun commentaire:

Enregistrer un commentaire