0
In my method of adding ta files giving the following Exception when debugging:
Validation failed for one or more entities. See 'Entityvalidationerrors' Property for more Details.
Method:
internal void AddArquivo(Model.Arquivo arquivo)
{
using (var ctx = new TESTEntities())
{
var versao = arquivo.ArquivoVersoes[0];
ctx.ARQUIVO.Add(new ARQUIVO()
{
ARQUIVO_GUID = arquivo.ARQUIVO_GUID,
ARQUIVO_VERSAO = new ARQUIVO_VERSAO()
{
ARQUIVO_GUID = arquivo.ARQUIVO_GUID,
ARQUIVO_VERSAO_GUID = Guid.NewGuid().ToString(),
ARQUIVO = versao.ARQUIVO,
DATAHORA = versao.DATAHORA,
TAMANHO = versao.TAMANHO,
USUARIO_PESSOA_GUID = versao.USUARIO_PESSOA_GUID
},
DIRETORIO_GUID = arquivo.DIRETORIO_GUID,
EXTENSAO = arquivo.EXTENSAO,
IS_STREAM = arquivo.IS_STREAM,
TAG = arquivo.TAG,
TIPO_DE_ARQUIVO_GUID = arquivo.TipoDeArquivo.TIPO_DE_ARQUIVO_GUID,
ULT_ARQUIVO_VERSAO_GUID = arquivo.ULT_ARQUIVO_VERSAO_GUID,
URL = arquivo.URL,
XARQUIVO = arquivo.XARQUIVO
});
ctx.SaveChanges();
}
}
You’ve already implemented this?
– Leonel Sanches da Silva
@Warlock, you need a catch with a Dbentityvalidationexception, have a great example posted by Gypsy: http://answall.com/questions/38119/erro-ao-updateds-no-entity-framework/38175#38175
– Tobias Mesquita
I did, it was in the context of my project, where I had GUID.neGuid.Tostring() so it generates a randomized Guid with characters, and in my context did not accept, so I used a library q already has ready in the project, which formed in the correct way, Util.Util.Guids.Getguid(),
– War Lock
@Tobymosque gives a look at the other theme I created, thanks.
– War Lock