Próbuję ustawić relacje mojego modelu w EF7, ale napotkałem problem: OnModelCreating
metoda i DbModelBuilder
są niezdefiniowane.OnModelCreating undefined w Entity Framework 7
W przeszłości używałem EF6, ale teraz próbuję przejść na EF7.
Oto mój kod
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//Section -> many Category
modelBuilder.Entity<Section>()
.HasMany<Category>(p => p.Categories)
.WithRequired(p => p.Section);
//Section -> many PriceCategory
modelBuilder.Entity<Section>()
.HasMany<PriceCategory>(p => p.PriceCategories)
.WithRequired(p => p.Section);
//Category - many Procedures
modelBuilder.Entity<Category>()
.HasMany<Procedure>(p => p.Procedures)
.WithRequired(p => p.Category);
//PriceCategory - many PriceProcedures
modelBuilder.Entity<PriceCategory>()
.HasMany<PriceProcedure>(p => p.PriceProcedures)
.WithRequired(p => p.PriceCategory);
}
Moi import:
using Microsoft.Data.Entity;
using Domain.Models;
Moja project.json:
{
"version": "1.0.0-*",
"description": "Domain Class Library",
"authors": [ "Garrus" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
},
"frameworks": {
"net451": { },
"dnxcore50": {}
}
}
Czy możesz mi pomóc? Może zapomniałem o pakiecie NuGet, czy istnieje inny sposób na ustawienie relacji modelu w EF7?
Właśnie wiedziałem, że metoda ** OnConfiguring ** również jest niezdefiniowana. –