C
C#2mo ago
Exdraem

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
Keswiik
Keswiik2mo ago
what command are you using to create the migration?
Exdraem
ExdraemOP2mo ago
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.
many things
many things2mo ago
'System.Runtime, Version=10.0.0.0 version 10?
Exdraem
ExdraemOP2mo ago
That correct. i've idea why.
jcotton42
jcotton422mo ago
@Exdraem could you please share your entire project file? as well as the output of dotnet --info? place them in backticks, like as in $code
MODiX
MODiX2mo ago
To 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/
Exdraem
ExdraemOP2mo ago
shure. give an moment
Exdraem
ExdraemOP2mo ago
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!
Exdraem
ExdraemOP2mo ago
Not shure. i should upload the entire Project Folder. In this case, i would share the zipe file or so.
jcotton42
jcotton422mo ago
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 you
Exdraem
ExdraemOP2mo ago
ok, but the link without context should open more questens to the beginning
Angius
Angius2mo ago
It works just fine with required
jcotton42
jcotton422mo ago
But EF fills it in for you. even when you new it up yourself
Angius
Angius2mo ago
Yeah, but I prefer required to = null! And I never new up the context manually So works for me
Exdraem
ExdraemOP2mo ago
Well. 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. Hey short update. I've now installed an entire new VM with win 11 Pro and VS. i also created an new project on it with the same Error Message. I anyone has an idea, im happy to hear it.

Did you find this page helpful?