Efcore: Discussion on using EF Core in an interactive C# Jupyter notebook

Created on 30 Nov 2020  路  7Comments  路  Source: dotnet/efcore

In my Case, I need to work on Efcore example with data annotations but it can't mapped when migrations happened in the interactive environment
image

the result is the [Key] annotation or any schema annotation not mapped in current migrations
image

customer-reported

Most helpful comment

@jonsequitur Thanks for jumping in here. I love this integration of EF Core into notebooks! Let's work together with @JeremyLikness to track potential improvements/extensions to the experience.

All 7 comments

Are these features not working in the interactive c# ?

I think the fluent API can work good in this environment

We are working on support for auto-scaffolding in .NET Interactive but haven't tried actually creating the model in a notebook yet.

https://github.com/dotnet/interactive/pull/870

In very basic app without any package installation requiring, the app can detect the annotations so annotations are working.
Though I run into issue when trying to install EFCore.SqlServer package

image

This issue should probably investigated by team which owns C# support in jupyter notebooks as it seems like there are multiple hoops to jump through even before reaching EF Core phase here.

@smitpatel, the stack trace indicates you're using an early preview of Jupyter support in the dotnet-try tool. Please run the following to update:

> dotnet tool install -g Microsoft.dotnet-interactive
> dotnet interactive jupyter install

One potential reason for the error you're seeing is that the version you're running targets .NET Core 3.0, but #r nuget without a version specification will grab EF 5.

That said, I don't expect the issue that @AhmedKhalil777 raised to work in any version, nor do I think it can be fixed within C# scripting. C# scripting's assembly model is quite different from what EF expects, which I'm guessing is the problem. In effect, @AhmedKhalil777's two different code cells are compiled into two different assemblies.

One thing to try is to put all of the code into a single cell and see if that works.

@jonsequitur Thanks for jumping in here. I love this integration of EF Core into notebooks! Let's work together with @JeremyLikness to track potential improvements/extensions to the experience.

Putting this in the discussion milestone for other discussion on the experience with interactive notebooks.

Thanks much @ajcvickers , @jonsequitur , @smitpatel for this discussion, returning to my notebook , my notebook worked perfectly , I don't know why, but reinstalling the assemblies again make it works, so I think there are some changes happened on these packages.

The integration between jupyter notebook and .Net world is something so beauty, and this make students and university teachers and scientists bring .Net with their environment, thanks much .Net team and enjoy coding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgribaudo picture bgribaudo  路  3Comments

miguelhrocha picture miguelhrocha  路  3Comments

spottedmahn picture spottedmahn  路  3Comments

MontyGvMC picture MontyGvMC  路  3Comments

julienshepherd picture julienshepherd  路  3Comments