EntityFrameworkCore. Basic exercice. Problem with add-migration.
Posted: Tue Jun 05, 2018 6:03 am
Hi All,
I'm using X# Core and I'm trying to do a very basic exercice that you can find here:
http://www.entityframeworktutorial.net/ ... ation.aspx.
(I've no problems when I do this exercice using C#. Maybe it's only a connection string problem ?)
Problem occurs when i apply: add-migration CreateSchoolDB
I get the following error:
"Constructor not found. Unable to find an appropriate constructor for the type System.Runtime.Versioning.FrameworkName."
(I've not the problem when I do it in C#)
NuGet packages are installed
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
About using:
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Data.Linq
USING system.data.SqlClient
USING System.Text
USING System.Threading.Tasks
USING Microsoft.EntityFrameworkCore
USING Microsoft.EntityFrameworkCore.Design
I created the following classes from the c# code:
CLASS Student
PUBLIC PROPERTY StudentID AS INT AUTO
PUBLIC PROPERTY Name AS STRING AUTO
CONSTRUCTOR()
RETURN
END CLASS
CLASS Course
PUBLIC PROPERTY CourseID AS INT AUTO
PUBLIC PROPERTY CourseName AS STRING AUTO
CONSTRUCTOR()
RETURN
END CLASS
CLASS SchoolContext INHERIT DbContext
PUBLIC PROPERTY Students AS DbSet<Student> AUTO
PUBLIC PROPERTY Courses AS DbSet<Course> AUTO
PROTECTED OVERRIDE METHOD OnConfiguring( optionsBuilder AS DbContextOptionsBuilder) AS VOID
LOCAL cString AS STRING
cString:= e"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
optionsBuilder.useSqlServer(cString)
END CLASS
Is the connection string ok?
in c#:
optionsBuilder.UseSqlServer(@"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;")
I tried with:
e"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
"Server=localhostSQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
Thank you
Guy DEPREZ
I'm using X# Core and I'm trying to do a very basic exercice that you can find here:
http://www.entityframeworktutorial.net/ ... ation.aspx.
(I've no problems when I do this exercice using C#. Maybe it's only a connection string problem ?)
Problem occurs when i apply: add-migration CreateSchoolDB
I get the following error:
"Constructor not found. Unable to find an appropriate constructor for the type System.Runtime.Versioning.FrameworkName."
(I've not the problem when I do it in C#)
NuGet packages are installed
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
About using:
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Data.Linq
USING system.data.SqlClient
USING System.Text
USING System.Threading.Tasks
USING Microsoft.EntityFrameworkCore
USING Microsoft.EntityFrameworkCore.Design
I created the following classes from the c# code:
CLASS Student
PUBLIC PROPERTY StudentID AS INT AUTO
PUBLIC PROPERTY Name AS STRING AUTO
CONSTRUCTOR()
RETURN
END CLASS
CLASS Course
PUBLIC PROPERTY CourseID AS INT AUTO
PUBLIC PROPERTY CourseName AS STRING AUTO
CONSTRUCTOR()
RETURN
END CLASS
CLASS SchoolContext INHERIT DbContext
PUBLIC PROPERTY Students AS DbSet<Student> AUTO
PUBLIC PROPERTY Courses AS DbSet<Course> AUTO
PROTECTED OVERRIDE METHOD OnConfiguring( optionsBuilder AS DbContextOptionsBuilder) AS VOID
LOCAL cString AS STRING
cString:= e"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
optionsBuilder.useSqlServer(cString)
END CLASS
Is the connection string ok?
in c#:
optionsBuilder.UseSqlServer(@"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;")
I tried with:
e"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
"Server=.SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
"Server=localhostSQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;"
Thank you
Guy DEPREZ