我试图将Repository Pattern与UnitOfWork一起使用,Section模型工作正常,但对于Country模型,它正在搜索dbo.Countries'在数据库中。
以下是国家模型的实施。
这是我的ModelClass
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EastWest.ViewModels;
namespace EastWest.BAL
{
public interface ICountryRepository : IRepository<Country>
{
}
}
ICountryRepositry.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using EastWest.ViewModels;
namespace EastWest.BAL
{
public class CountryRepository : Repository<Country>, ICountryRepository
{
public CountryRepository(DbContext _db)
{
db = _db;
}
}
}
CountryRepository
private IUnitOfWork iUnitOfWork;
public CountriesController()
{
this.iUnitOfWork = new UnitOfWork();
}
// GET: Countries
public ActionResult Index()
{
return View(iUnitOfWork.Country.GetAll().ToList());
}
CountriesController
Invalid object name 'dbo.Countries'
错误
public class Abc {
private Integer value1;
private Integer value2;
private Integer value3;
private Integer value4;
public Abc(){
}
public Integer getValue1() {
return value1;
}
public void setValue1(Integer value1) {
this.value1 = value1;
}
public Integer getValue2() {
return value2;
}
public void setValue2(Integer value2) {
this.value2 = value2;
}
public Integer getValue3() {
return value3;
}
public void setValue3(Integer value3) {
this.value3 = value3;
}
public Integer getValue4() {
return value4;
}
public void setValue4(Integer value4) {
this.value4 = value4;
}
}
同样的实现适用于我的另一个表(模型)部分。