تغییر در مدل در entity framework database first
سلام دوستان
من یک دیتا بیس اماده و پر از داده دارم خواستم برای گسترش ان تحت mvc انرا به روش database first وارد پروژه خودم بکنم
تمام مراحل را راحت انجام میدم و فایل با پسوند edmx با کلاس های مربوط به هر جدول ساخته میشه و حتی اطلاعات را هم به راحتی واکشی میکنم
فقط میخوام بتوانم از داخل پروژه و با تغییر DataAnnotations ها بتوانم مقادیر مثلا stringlenght و غیره وحتی ستون خاصی به جدول خاصی اضافه کنم ولی نمیدونم چطوری باید این کار رو بکنم خواهشن کمک کنید کارم چند روزه گیره همین قسمته
نقل قول: تغییر در مدل در entity framework database first
سلام.
در روش Database First من چیزی ندیدم که بشه باهاش اینکار رو کرد.
نقل قول: تغییر در مدل در entity framework database first
نقل قول:
نوشته شده توسط
a.golzar66
سلام دوستان
من یک دیتا بیس اماده و پر از داده دارم خواستم برای گسترش ان تحت mvc انرا به روش database first وارد پروژه خودم بکنم
تمام مراحل را راحت انجام میدم و فایل با پسوند edmx با کلاس های مربوط به هر جدول ساخته میشه و حتی اطلاعات را هم به راحتی واکشی میکنم
فقط میخوام بتوانم از داخل پروژه و با تغییر DataAnnotations ها بتوانم مقادیر مثلا stringlenght و غیره وحتی ستون خاصی به جدول خاصی اضافه کنم ولی نمیدونم چطوری باید این کار رو بکنم خواهشن کمک کنید کارم چند روزه گیره همین قسمته
databasefirst برای اینکار نیست . بلکه کد فرست هست . کد فرست بابت همین موضوع اومده و در دیتابیس فرست جنریت شما از سمت دیتابیس همیشه خواهد بود . پس شدنی نیست
نقل قول: تغییر در مدل در entity framework database first
بسیار ممنون
پس این روش ارتباط دادن metadata class به کلاس اصلی چیه؟
نقل قول: تغییر در مدل در entity framework database first
نقل قول:
پس این روش ارتباط دادن metadata class به کلاس اصلی چیه؟
Metadata هایی مثل StringLength اگر روش Code First باشه روی ستون مربوطه در دیتابیس هم اثر می گذارند، اما اگر روش Database First باشه فقط کار اصلی اش، یعنی محدود کردن تعداد کاراکترهای ورودی در Input مربوطه در سمت رابط کاربری رو انجام میدن.
نقل قول: تغییر در مدل در entity framework database first
البته شما می توانید یک دیتابیس آماده رو با استفاده از EF به حالت Code First هم تبدیل کنید
نقل قول: تغییر در مدل در entity framework database first
نقل قول:
نوشته شده توسط
hakim22
البته شما می توانید یک دیتابیس آماده رو با استفاده از EF به حالت Code First هم تبدیل کنید
دوست عزیز یعنی چطور میشه یه توضیح کوچیک بدی؟چون با کدفرست خیلی راحت تر میشه ارتباطات رو پیاده سازی کرد
نقل قول: تغییر در مدل در entity framework database first
نقل قول:
نوشته شده توسط
a.golzar66
دوست عزیز یعنی چطور میشه یه توضیح کوچیک بدی؟چون با کدفرست خیلی راحت تر میشه ارتباطات رو پیاده سازی کرد
اینم یه حرف درستیه که حکیم زده پس اگر دیتابیست اماده باشه میتونی با Entity Framework Power Tools Beta 4 میتونی انجامش بدی
نقل قول: تغییر در مدل در entity framework database first
نقل قول: تغییر در مدل در entity framework database first
همچنین می توانید درون پروژه گزینه ی Add و بعد New Item رو بزنید. در قسمت Data به ADO.NET Entity model بروید و گزینه ی CodeFirst From Database رو بزنید.
این گزینه ها در ASP Core نیست و باید از افزونه ی بالا استفاده کنید. بخش Designer کلا در EF Core حذف شده .