1

Closed

Null reference exception

description

Hello Jonathan.

Thank you for your work on Z Extension Methods :)

I have an entity class containing a property of an enum type. When I try to bulk insert entities of this type I encounter a null reference exception in DbContext.GetCodeFirstModel.cs: line 136.
The same operation works if I change my property type to int.
public enum EfecteTemplateEnum
{
    Contract,
    Customer,
    DeliveryPoint,
    Meter,
    Product,
    ServiceLine
}

public class EfecteDataCard : IEfecteEntity
{
    [Key, Column(Order = 0)]
    public EfecteTemplateEnum Template { get; set; }

    [Key, Column(Order = 1)]
    public string Key { get; set; }

    public DateTime? LastUpdated { get; set; }
}
System.NullReferenceException : Object reference not set to an instance of an object.
at DbContexttExtension.BuildConceptual(Model model, Edmx edmx) in c:\Users\Jonathan\Desktop\Z\TFS\zExtensionMethods\Z.ExtensionMethods.EntityFramework\DbContext\Model\DbContext.GetCodeFirstModel.cs: line 136
at DbContexttExtension.GetCodeFirstModel(DbContext this) in c:\Users\Jonathan\Desktop\Z\TFS\zExtensionMethods\Z.ExtensionMethods.EntityFramework\DbContext\Model\DbContext.GetCodeFirstModel.cs: line 35
at DbContexttExtension.GetModel(DbContext this) in c:\Users\Jonathan\Desktop\Z\TFS\zExtensionMethods\Z.ExtensionMethods.EntityFramework\DbContext\Model\DbContext.GetModel.cs: line 26
at DbContexttExtension.SqlBulkInsert(DbContext this, IEnumerable1 entities, SqlBulkCopyOptions copyOptions, SqlTransaction transaction, Action1 sqlBulkCopyFactory) in c:\Users\Jonathan\Desktop\Z\TFS\zExtensionMethods\Z.ExtensionMethods.EntityFramework\DbContext\BulkOperation\DbContext.SqlBulkInsert.cs: line 0
at DbContexttExtension.SqlBulkInsert(DbContext this, IEnumerable1 entities) in c:\Users\Jonathan\Desktop\Z\TFS\zExtensionMethods\Z.ExtensionMethods.EntityFramework\DbContext\BulkOperation\DbContext.SqlBulkInsert.cs: line 141
at VAD.Data.Commands.impl.InsertCommand
1.<>c__DisplayClass1.<ExecuteCommand>b__0() in InsertCommand.cs: line 13
at VAD.Data.Commands.CommandExtension.WithConnection(ICommand1 this, IUnitOfWork unitOfWork, Action a) in ICommand.cs: line 33
at VAD.Data.Commands.impl.InsertCommand
1.ExecuteCommand(IUnitOfWork unitOfWork, IEnumerable1 commandInput) in InsertCommand.cs: line 13
at VAD.EfecteIntegrationService.DataCardHandler.DataCardImport(IEnumerable
1 messages, DateTime timestamp, String folder) in DataCardHandler.cs: line 113
at VAD.EfecteIntegrationService.DataCardHandler.DataCardImport(ContractCommand command, String folder) in DataCardHandler.cs: line 46
at VAD.IntegrationTest.EfecteIntegrationService.DataCardHandlerTest.Test() in DataCardHandlerTest.cs: line 68

Best Regards
Martin
Closed Jun 4, 2014 at 12:37 AM by Jonathan_Magnan
Closing this issue, this should have been fixed in v1.1.4.2 and no answer after 2 weeks.

comments

Jonathan_Magnan wrote May 13, 2014 at 4:29 PM

Thank you Martin for the compliment ;)

Are you using the latest version of Entity Framework Extensions?

This bug look exactly like the one someone else reported to me few week ago. This has been fixed in v1.1.4.2.

Let me know if you still have the bug.

Best Regards
Jonathan

wrote Jun 4, 2014 at 12:37 AM