저는 EntityFramework 및 Core에서 정말 초보자입니다.EntityFramework 코어에서 간단한 데이터베이스를 만들 수 없습니다.
EntityFramework Core 2.0에서 간단한 DataBase를 만들고 싶습니다. 이 프로젝트는 Microsoft.AspNetCore.All by Nuget 패키지에 포함 된 ConsoleApplication입니다. 이것은 코드입니다 :
namespace TestEF
{
class Program
{
static void Main(string[] args)
{
string connStr = "Server=(localdb)\\mssqllocaldb;Database=SchoolDataBase;Trusted_Connection=True;MultipleActiveResultSets=true";
var db = new SchoolContext(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connStr).Options);
db.Students.Add(
new Student()
{
LastName = "Miranda",
EnrollmentDate = DateTime.Now,
FirstMidName = "Guillermo"
});
db.SaveChanges();
Console.WriteLine("Hello World!");
Console.ReadLine();
}
}
public class Student
{
public int ID { get; set; }
public string LastName { get; set; }
public string FirstMidName { get; set; }
public DateTime EnrollmentDate { get; set; }
}
public class SchoolContext : DbContext
{
public SchoolContext(DbContextOptions options) : base(options)
{
}
public DbSet<Student> Students { get; set; }
}
}
나는 사용자 이름 "gmiranda"로 인트라넷에 로그인합니다. 나는이 프로젝트를 실행할 때 나는 다음과 같은 메시지 오류 :
System.Data.SqlClient.SqlException가 HRESULT = 0x80131904 메시지를 발생 = 로그인으로하지 데이터베이스 "SchoolDataBase"을 요청 할 수 있습니다. 로그인에 실패했습니다. 'domain \ gmiranda'사용자가 로그인하지 못했습니다.
내가 뭘 잘못하고 있니? 감사합니다.