Hallo,
Ich habe alle Tabellen in der Datenbank angepasst und nun kann ich es nicht mehr generieren.
Was ich schon gemacht habe1. Datenbank gelöscht (Remove-Migration)
Ich hab auch schon jegliche Reihenfolge versucht sowohl auch die Befehle via CMD ( google hat mir erzählt das sollte einen unterschied machen)
Zuletzte habe ich diesen Output bekommen
PM> dotnet ef migrations add newDatabase
\\Mac\Home\Documents\Project\ThePLCProjekt\ThePLCProjekt\obj\ThePLCProjekt.csproj.EntityFrameworkCore.targets(4,5): error MSB4006: Im Zielabhängigkeitsdiagramm besteht eine Ringabhängigkeit im Zusammenhang mit dem Ziel "GetEFProjectMetadata". [\\Mac\Home\Documen
ts\Project\ThePLCProjekt\ThePLCProjekt\ThePLCProjekt.csproj]
Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
PM>
public class MyDB : DbContext
{
public DbSet<PLCTyp> PlcSets { get; set; }
// public DbSet<DBTyp> DbSets { get; set; }
public DbSet<VarTyp> VarSets { get; set; }
public MyDB()
{
}
public void ClearDatabase()
{
Database.EnsureDeleted();
}
public void CreateDatabase()
{
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=MyDatabase.sqlite");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
/* modelBuilder.Entity<DBTyp>()
.HasOne(p => p.PLCTyp)
.WithMany(b => b.DbSets)
.HasForeignKey(p => p.PLCTypId);
modelBuilder.Entity<VarTyp>()
.HasOne(p => p.DBTyp)
.WithMany(b => b.VarSets)
.HasForeignKey(p => p.DBTypId); */
modelBuilder.Entity<VarTyp>()
.HasOne(p => p.PLCTyp)
.WithMany(b => b.VarSets)
.HasForeignKey(p => p.PLCTypId);
}
}
public class PLCTyp
{
public int PLCTypId { get; set; }
public string Name { get; set; }
public string IP { get; set; }
public string Target { get; set; }
public int Cycle { get; set; }
public List<VarTyp> VarSets { get; set; }
}
public class VarTyp
{
public int VarTypId { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string DataTyp { get; set; }
public string Event { get; set; }
public int PLCTypId { get; set; }
public PLCTyp PLCTyp { get; set; }
}
/*
public class PLCTyp
{
public int PLCTypId { get; set; }
public string name { get; set; }
public string ip { get; set; }
public string target { get; set; }
public int cycle { get; set; }
public List<DBTyp> DbSets { get; set; }
}
public class DBTyp
{
public int DBTypId { get; set; }
public string name { get; set; }
public int adress { get; set; }
public int offset { get; set; }
public int lengh { get; set; }
public int PLCTypId { get; set; }
public PLCTyp PLCTyp { get; set; }
public List<VarTyp> VarSets { get; set; }
}
public class VarTyp
{
public int VarTypId { get; set; }
public string name { get; set; }
public int offset { get; set; }
public int lengh { get; set; }
public int varId { get; set; }
public int DBTypId { get; set; }
public DBTyp DBTyp { get; set; }
}
*/
Ich habe zur letzten Meldung nicht mehr viel gefunden, evtl hätte jemand rat für mich
Schon mal vielen Dank.
Gruß
Siehe Fehlermeldung: Du hast eine Ringabhängigkeit.
Das geht nicht.
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code
Ja das hat ich auch schon gelesen, aber wie oben schon geschrieben kann ich damit nichts anfangen.
Entschuldige für die Dumme Frage aber was ist damit denn gemeint?
Gruß
Google einfach nach dem MS Build Fehlercode; dafür ist er da.
Ein Ringverweis entsteht, wenn Du Projekte falsch verweist:
Damit wurde eine nicht lösbare Ringabhängigkeit hergestellt und es knallt.
Hast wohl beim Aufräumen nicht 100% aufgepasst 😉
Dass es dazu kommt ist ein Zeichen, dass man sich nicht an die Empfehlungen von Projektstrukturen hält 😃
- performance is a feature -
Microsoft MVP - @Website - @AzureStuttgart - github.com/BenjaminAbt - Sustainable Code