خطای Keyword not supported: source هنگام اتصال پایگاه داده در Entity Framework
با سلام
برای ساخت فایل ستاپ از پروژه با روش Install Aware اومدم از دیتابیس یک کویری ساختم که فایل رو با sql server experess بسازم تا فایل .mdf رو در دایرکتوری پروژه در کانکشن استرینگ اپ کانفیگ قرار بدم اما فکر میکنم مشکلی در کانکشن استرینگ من وجود داره که نمیشه.
این روش رو برای برنامه ای که به صورت ADO.NET به دیتابیس متصل شده بود رو انجام دادم و مشکلی نداشت اما با برنامه ای که با entity framework به دیتابیس متصل شده بود هرکاری کردم به نتیجه نرسیدم.
کد کانکشن استرینگ برنامه ای که با entity framework به دیتابیس متصل می شود به طور معمول این است:
<connectionStrings>
<add name="Notes_DBEntities" connectionString="metadata=res://*/Nete_Model.csdl|res://*/Nete_Model.ssdl|res://*/Nete_Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Notes_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
از کانکشن استرینگ های مختلفی استفاده کردم اما جواب نداد.
مانند:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Notes_DB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
اما به صورت معمول برنامه ای که با ADO.NET نوشته بودم مشکلی نداشت.
خطایی که دریافت میکنم :
System.ArgumentException HResult=0x80070057 Message=Keyword not supported: 'data source'. Source=EntityFramework StackTrace: at System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions.ParseInternal(IDictionary`2 parsetable, String connectionString, IList`1 validKeywords) at System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions..ctor(String connectionString, IList`1 validKeywords) at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString) at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at DataLayer.NotesRepository.GetNotes() in D:\Projects\C#\Notes\DataLayer\Services\NotesRepository.cs:line 22 at Notes.Form1.BindGrid() in D:\Projects\C#\Notes - Copy (2)\Notes\Form1.cs:line 31 at Notes.Form1.Form1_Load(Object sender, EventArgs e) in D:\Projects\C#\Notes - Copy (2)\Notes\Form1.cs:line 24 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
: System.Data.Entity.Core.EntityException HResult=0x80131501 Message=The underlying provider failed on ConnectionString. Source=EntityFramework StackTrace: at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString) at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) at System.Data.Entity.Internal.LazyInternalConnection.Initialize() at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at DataLayer.NotesRepository.GetNotes() in D:\Projects\C#\Notes\DataLayer\Services\NotesRepository.cs:line 22 at Notes.Form1.BindGrid() in D:\Projects\C#\Notes - Copy (2)\Notes\Form1.cs:line 31 at Notes.Form1.Form1_Load(Object sender, EventArgs e) in D:\Projects\C#\Notes - Copy (2)\Notes\Form1.cs:line 24 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) This exception was originally thrown at this call stack: [External Code] Inner Exception 1: ArgumentException: Keyword not supported: 'source'.
همچنین این خطا رو هم میده
SqlException: Unable to open the physical file "D:\Projects\C#\Notes - Copy (2)\Notes\bin\Debug\Notes_DB.mdf". Operating system error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file D:\Projects\C#\Notes - Copy (2)\Notes\bin\Debug\Notes_DB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
خطای شما به این خاطر هست که کانکشن استرینگ در ORM های مختلف متفاوت هست. احتمالا شما رشته اتصال خودتون رو به حالت Ado.net دارید می نویسید. لینک زیر رو مطالعه کنید دقیقا همین خطا رو داشته :
دلیل خطای Keyword not supported: data source در انتیتی فریم ورک Code First
خطای دومی هم که قرار دادید که Access id denied هست. یعنی دسترسی به دیتابیس در سیستم عامل شما وجود نداره. باید دسترسی ها یا محل ذخیره سازی دیتابیس رو بررسی کنید. اطلاعات شما از سوال کم هست و نمیشه به دقت پاسخی گفت.
- آموزش استفاده از SignalR در Asp.net Core با مثال عملی
- ادغام چند گزارش استیمول سافت بصورت پی دی اف در یک فایل
- نحوه تغییر استایل کامپوننت select2 چگونه است ؟
- چگونه امنیت پروژه را در Asp.net Core افزایش دهیم ؟
- ارسال پارامتر در دستور window.open جی کویری
- ارسال پارامتر از طریق جاوااسکریپت با کلیک روی تگ a
- خطای 500 زمان اجرا شدن پروژه روی هاست
- کویری نویسی در استیمول سافت جهت فیلتر اطلاعات
- نمایش صفحه در پنجره جدید با کلیک روی لینک (تگ a) در Asp
- افزودن مقادیر به صورت دستی به List دریافت شده از ریپازیتوری
- مشکل تاریخ شمسی در سی شارپ
- نمایش گزارش stimulsoft روی کلاینت
- حذف کامل یک رکورد در جدول ریلیشن شده
- تفاوت های سی شارپ 8 با نسخه های قبلی چیه؟
- انتخاب چند سطر دلخواه توسط چک باکس در DataGrid و محاسبه جمع سطرهای انتخاب شده
- مقایسه ساختار دو دیتابیس در Sql Server
- اشکال در ایجاد کلید خارجی در Sql Server
- نمایش نوتیفکیشن در سی شارپ
- ارسال پارامتر از سی شارپ به استیمول سافت
- عدم نمایش عکس در دیتاگرید ویو در wpf