저는 코드 첫 번째 Entity Framework를 새로 도입했습니다.SQL Azure에서 테이블을 작성하기위한 코드 우선 Entity Framework 가져 오기
지금 몇 가지 시도했지만 EF에서 내 SQL Azure 데이터베이스의 모든 테이블을 구성 할 수 없습니다. 누군가 확인해야하는 단계 및 설정에 대해 조언 할 수 있습니까?
멤버 자격 공급자는 테이블을 만들 때 아무런 문제가 없습니다.
연결 문자열에 PersistSecurityInfo = True를 추가했습니다. 연결 문자열이 서버의 주 사용자 계정을 사용하고 있습니다.
SQL을 사용하여 데이터베이스에 테이블을 구현하면 모든 것이 잘 동작합니다.
나는하여 WebRole.cs에 다음이 나는 테이블에 액세스 할 때 나는 "잘못된 개체 이름 'dbo.ClientAccountIFAs'을."도착하기 전에 실행되지 않습니다
//Initialize the database
Database.SetInitializer<ReykerSCPContext>(new DbInitializer());
내 DbInitializer (처음. 언젠가
public class DbInitializer:DropCreateDatabaseIfModelChanges<ReykerSCPContext>
{
protected override void Seed(ReykerSCPContext context)
{
using (context)
{
//Add Doc Types
context.DocTypes.Add(new DocType() { DocTypeId = 1, Description = "Statement" });
context.DocTypes.Add(new DocType() { DocTypeId = 2, Description = "Contract note" });
context.DocTypes.Add(new DocType() { DocTypeId = 3, Description = "Notification" });
context.DocTypes.Add(new DocType() { DocTypeId = 4, Description = "Invoice" });
context.DocTypes.Add(new DocType() { DocTypeId = 5, Description = "Document" });
context.DocTypes.Add(new DocType() { DocTypeId = 6, Description = "Newsletter" });
context.DocTypes.Add(new DocType() { DocTypeId = 7, Description = "Terms and Conditions" });
//Add ReykerAccounttypes
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 1, Description = "ISA" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 2, Description = "Trading" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 3, Description = "SIPP" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 4, Description = "CTF" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 5, Description = "JISA" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 6, Description = "Direct" });
context.ReykerAccountTypes.Add(new ReykerAccountType() { ReykerAccountTypeID = 7, Description = "ISA & Direct" });
//Save the changes
base.Seed();
}
시작. 이후 내 DBContext 클래스는 보이는
public class ReykerSCPContext : DbContext
{
//set the connection explicitly
public ReykerSCPContext():base("ReykerSCPContext"){}
//define tables
public DbSet<ClientAccountIFA> ClientAccountIFAs { get; set; }
public DbSet<Document> Documents { get; set; }
public DbSet<DocType> DocTypes { get; set; }
public DbSet<ReykerAccountType> ReykerAccountTypes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//Runs when creating the model. Can use to define special relationships, such as many-to-many.
}
같은 414,액세스하는 데 사용되는 코드는
public List<ClientAccountIFA> GetAllClientAccountIFAs()
{
using (DataContext)
{
var caiCollection = from c in DataContext.ClientAccountIFAs
select c;
return caiCollection.ToList();
}
}
하고 마지막 줄에 오류가 발생합니다. Help!