Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for InsertFromQuery + InMemory #477

Open
groberts71 opened this issue Mar 19, 2022 · 4 comments
Open

Add Support for InsertFromQuery + InMemory #477

groberts71 opened this issue Mar 19, 2022 · 4 comments
Assignees

Comments

@groberts71
Copy link

groberts71 commented Mar 19, 2022

Description

When attempting to use InsertFromQuery with the Microsoft InMemory database it throws the exception below.

Our unit tests at present are based on the InMemory database. We are hoping you might be able to add in support for this rather than us having to find a workaround (or not have unit tests).

Exception

Unhandled exception. System.Exception: Oops! This scenario is not yet support for InsertFromQuery + InMemory.
at 1.(IQueryable1 , Action1 ) at 1.Execute(IQueryable1 query, Action1 batchInsertBuilder)
at DbContextExtensions.[](IQueryable1 , Action1 )
at DbContextExtensions.[](IQueryable1 , String , String , String , Type , Expression1 )
at DbContextExtensions.InsertFromQuery[TEntity](IQueryable1 query, String tableName, Expression1 selectExpression)
at InsertFromQuery.Program.Main()
Command terminated by signal 6

Fiddle or Project (Optional)

https://dotnetfiddle.net/NfpB4n

Further technical details

  • EF version: 6.0.3
  • EF Extensions version: 6.13.15
  • Database Provider: InMemory
@JonathanMagnan JonathanMagnan self-assigned this Mar 21, 2022
@JonathanMagnan
Copy link
Member

Hello @groberts71 ,

We indeed do not support that feature with InMemory yet.

We will look at what we can do.

Best Regards,

Jon

@JonathanMagnan
Copy link
Member

Hello @groberts71 ,

My developer investigated this issue to find out what it will possible to do and what would be the limitation.

First, we would like to understand your scenario to see if we can support it or not.

You currently try to insert to the zcustomerdest table in your example. What's this memory table? It doesn't seem to be mapped anywhere. It's a table that exists via another DbSet such as public DbSet<CustomerDest> zcustomerdest { get; set; }? Or this is a new table that needs to be created?

Also how the table name is mapped (zcustomerdest)? The Table data annotation is not very friendly with InMemory provider, however mapping it using the API with the ModelBuilder (ToTable("zcustomerdest")`) seem to don't have problem

Best Regards,

Jon

@groberts71
Copy link
Author

Hi Jon,

In answer to your questions about the real scenario on our side -
(1) The zcustomerdest table is pre-existing and does not need to be created.

(2) The example code was just for illustrative purposes and pared down to absolute bare basics. Maybe I went too far. in removing the destination table mapping.... :-) The zcustomerdest table is mapped within EF (i.e. there is a DbSet definition)

(3) We currently use the Table annotation, but can easily switch this to use Fluent API as part of any remediation effort to get this working.

Cheers,
Glenn

@JonathanMagnan
Copy link
Member

Thank @groberts71 for the additional information.

Just wanted to be sure that if we try to work on it that we could support your scenario ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants