بعد از ایجاد فایل Configuration.cs در پوشه Migrations توسط فرمان enable-migrations دستور زیر را در سازنده کلاس بنویسید 

AutomaticMigrationsEnabled = false;


فرمان enable-migrations بصورت زیر می باشد

enable-migrations -ContextTypeName Repository.PhoneBookContext -MigrationsDirectory:Migrations\PhoneBookContextMigration



تغیرات زیر را در DbContext جهت فقط خواندنی کردن آن اعمال کنید


public class MyReadOnlyContext : DbContext
{
    // Use ReadOnlyConnectionString from App/Web.config
    public MyReadOnlyContext () : base("Name=ReadOnlyConnectionString")
    {
           Configuration.LazyLoadingEnabled = false;
           Configuration.ProxyCreationEnabled = false;
           Configuration.ValidateOnSaveEnabled = false;
           Configuration.AutoDetectChangesEnabled = false;

    }

    // Don't expose Add(), Remove(), etc.
    public DbQuery<PhoneBook> PhoneBooks
    {
        get
        {
            // Don't track changes to query results
            return Set<PhoneBook>().AsNoTracking();
} } public override int SaveChanges() { // Throw if they try to call this throw new InvalidOperationException("This context is read-only."); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { // Need this since there is no DbSet<Customer> property modelBuilder.Entity<PhoneBook>();
} }

agile به زبان ساده و معرفی Scrum

مدیریت منابع انسانی در اسکرام

چرا با توجه به اینکه تنظیمات SMTP درست است ایمیل ارسال نمی شود؟

{ ,} ,false ,configuration ,public ,migrations ,false configuration ,فرمان enable migrations ,زیر را ,} } ,don t

مشخصات

تبلیغات

آخرین ارسال ها

برترین جستجو ها

آخرین جستجو ها

بلوک سبک آقای چاه پتانسیل کتاب Fernweh وبگاه شخصی محمد مافی بالانی دستگاه عرق گیری تقطیر گلاب گیری تقطیر خانگی(سایت تخصصی دستگاه عرق گیری اصفهان ) خرید و فروش کارخانه sahelaftab احسان پیروز