it seam Entity Framework dont like me. But i will force it to
Good evening together. I've experimenting with exntity Framework and im getting crazy about some basic stuff. Maybe here someone, who can help me.
In VSComunity i've created an .net Core 8 Web API and importet the follwing Pakages:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
I've also created an basic Model and App Context Class:
If needed. i can provide the Code of the classes.
If i try to Create an Migration on an mysql Server, that runs in Docker, i've getting the following Error after completing the Build:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Das System kann die angegebene Datei nicht finden.
File name: 'System.Runtime, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I've also try to user other Commands like Scaffold-dbContext with the same Error Message. Hope you've an info for me. how i can fix this.
Thanks ExDraem
15 Replies
what command are you using to create the migration?
I've tryed the Commands add-migration "Some Comment" and Scaffold-DBContext "Server=localhost;Database=db; UID=dbadmin; Pwd=Admin123!" Pomelo.EntityFrameworkCore.MySql -OutputDir Models
Both give me the same error message.
'System.Runtime, Version=10.0.0.0
version 10?That correct. i've idea why.
@Exdraem could you please share your entire project file?
as well as the output of
dotnet --info
?
place them in backticks, like as in $codeTo post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/shure. give an moment
i think i've all important files not copyed. Here is the Link:
https://paste.mod.gg/kaphjmdcyjui/5
BlazeBin - kaphjmdcyjui
A tool for sharing your source code with the world!
Not shure. i should upload the entire Project Folder. In this case, i would share the zipe file or so.
strange, that looks right
the only comments I have are that you should be using file-scoped namespaces, and the
required
in public required DbSet<Event> Events { get; set; }
in ApplicationDBContext
shouldn't be there
you may want to hop over to #database @Exdraem, bring that paste link with youok, but the link without context should open more questens to the beginning
It works just fine with
required
But EF fills it in for you.
even when you
new
it up yourselfYeah, but I prefer
required
to = null!
And I never new
up the context manually
So works for meWell. Thanks for your time to take a look on this. Only thing i can think of as some sort of cause is my machine. But for this i need to prepare another one. Maybe i can you you an Update in the next days.