C
C#2d 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
Keswiik2d ago
what command are you using to create the migration?
Exdraem
ExdraemOP2d 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.
this_is_pain
this_is_pain2d ago
'System.Runtime, Version=10.0.0.0 version 10?
Exdraem
ExdraemOP2d ago
That correct. i've idea why.
jcotton42
jcotton422d 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
MODiX2d 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
ExdraemOP2d ago
shure. give an moment
Exdraem
ExdraemOP2d 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
ExdraemOP2d ago
Not shure. i should upload the entire Project Folder. In this case, i would share the zipe file or so.
jcotton42
jcotton422d 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
ExdraemOP2d ago
ok, but the link without context should open more questens to the beginning
Angius
Angius2d ago
It works just fine with required
jcotton42
jcotton422d ago
But EF fills it in for you. even when you new it up yourself
Angius
Angius2d ago
Yeah, but I prefer required to = null! And I never new up the context manually So works for me
Exdraem
ExdraemOP2d 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.

Did you find this page helpful?