Base solution for your next web application
Open Closed

Power Tool not creating object in database #8331


User avatar
0
alfar_re created

Hi,

Am new to Zero. I am trying to play around with the RAD tool and based on my tests it seems there is a problem.

Either I'm missing something in config or just a bug. I found this error on the log 'Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Amenities'.

I was creating an entity named 'Amenities'. See below audit log. ---------------------------------------------------------

User information <label class="col-lg-3 col-form-label">User name:</label><label class="col-form-label" id="AuditLogDetailModal_UserName">admin</label><label class="col-lg-3 col-form-label">IP address:</label><label class="col-form-label" id="AuditLogDetailModal_ClientIpAddress">::1</label><label class="col-lg-3 col-form-label">Client:</label><label class="col-form-label" id="AuditLogDetailModal_ClientName"></label><label class="col-lg-3 col-form-label">Browser:</label><label class="col-form-label" id="AuditLogDetailModal_BrowserInfo">Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36</label>

Action information

<label class="col-lg-3 col-form-label">Service:</label><label class="col-form-label" id="AuditLogDetailModal_ServiceName">AmenitiesAppService</label><label class="col-lg-3 col-form-label">Action:</label><label class="col-form-label" id="AuditLogDetailModal_MethodName">CreateOrEdit</label><label class="col-lg-3 col-form-label">Time:</label><label class="col-form-label" id="AuditLogDetailModal_ExecutionTime">a minute ago (2020-01-11 07:13:19)</label><label class="col-lg-3 col-form-label">Duration:</label><label class="col-form-label" id="AuditLogDetailModal_Duration">7 ms</label><label class="col-lg-3 col-form-label">Parameters:</label>

{
    "input": {
        "description": "Parking",
        "id": null
    }
}
Custom data

None

Error state
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Amenities'.
   at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__164_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
ClientConnectionId:71a87cdb-5d9f-4a13-8b21-d290240c74a3
Error Number:208,State:1,Class:16
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.Batch...

2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Did Power Tools showed an error during the creation of Amenities entity ? It seems like migrations are not applied to your database.

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    There was an error with the power tool creating migrations and updating database. I found another queston with the same content and tried to follow the answer. Finally, I found an answer and applied it. And it worked.

    I just run this

    dotnet tool install --global dotnet-ef

    Thank you.