Entity Framework löst einen Fehler aus:
Test 'WorkerProcessService.Test.WorkerProcessMonitorTests.Test' failed: System.Data.UpdateException : Unable to update the EntitySet 'Processor' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
at System.Data.SqlClient.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression)
at System.Data.Common.CommandTrees.DbScanExpression.Accept(DbExpressionVisitor visitor)
at System.Data.SqlClient.SqlGen.DmlSqlGenerator.GenerateInsertSql(DbInsertCommandTree tree, SqlVersion sqlVersion, List`1& parameters)
at System.Data.SqlClient.SqlGen.SqlGenerator.GenerateSql(DbCommandTree tree, SqlVersion sqlVersion, List`1& parameters, CommandType& commandType, HashSet`1& paramsToForceNonUnicode)
at System.Data.SqlClient.SqlProviderServices.CreateCommand(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.SqlClient.SqlProviderServices.CreateCommand(DbCommandTree commandTree)
at System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(UpdateTranslator translator, Dictionary`2 identifierValues)
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
WorkerProcessMonitor.cs(79,0): at Star.Portal.Services.WorkerProcessMonitor.AddComponent(Byte[] component)
WorkerProcessMonitorTests.cs(55,0): at WorkerProcessService.Test.WorkerProcessMonitorTests.Test()
Ich habe eine Tabelle wie und ein automatisch generiertes edmx-Modell
CREATE TABLE [dbo].[Processor](
[ProcessorID] [int] IDENTITY(1,1) NOT NULL,
[ProcessorDLL] [varbinary](max) NULL,
)
Folgendes wird nicht aktualisiert
public void AddComponent(byte[] component)
{
Processor p = new Processor()
{
ProcessorDLL = component,
};
using (var cn = GetWorkerProcessEntities())
{
cn.AddToProcessors(p);
cn.SaveChanges();
}
}
Die Frage ist: Muss ich etwas Bestimmtes tun, um Binärspeicher in Sql Server zu implementieren?