Dziwne zachowanie designera przy Entity Framework

0

Witam,

W mojej aplikacji po stworzeniu modelu za pomoca ADO.NET Entity Data Model (edmx), designer zwraca mi exception.

Wszystko popodpinałem odpowiednio, w debug aplikacja działa i nie zwraca błedów, ale w designerze:

ModelValidationException: One or more validation errors were detected during model generation:

HP_Timer_Tool_Master_V3.tbl_Activities_First: : EntityType 'tbl_Activities_First' has no key defined. Define the key for this EntityType. HP_Timer_Tool_Master_V3.tbl_Activities_Second: : EntityType 'tbl_Activities_Second' has no key defined. Define the key for this EntityType. tbl_Activities_First: EntityType: EntitySet 'tbl_Activities_First' is based on type 'tbl_Activities_First' that has no keys defined. tbl_Activities_Second: EntityType: EntitySet 'tbl_Activities_Second' is based on type 'tbl_Activities_Second' that has no keys defined.

Dla tbl_Activities_First i tbl_Activities_Second mam ustanowione klucze...

Kiedy zamknę VS i uruchomię ponownie, wtedy w designerze pojawia się:

UnintentionalCodeFirstException: The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715

Connection string też mam dobry. Jest wpisany poprawnie.

Sprawdzam w Model.Context - wszystko jest poprawnie.

Komentuję:

 protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
	throw new UnintentionalCodeFirstException();
}

I wtedy designer wywala:

InvalidOperationException: The property 'FK_FirstID' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection where T is a valid entity type.

Spotkaliście się z czymś takim?

Bardzo dziękuję za podpowiedzi.

1

Connection string masz dobry, czyli w formacie EF? Z jakiej klasy dziedziczy Twój context?

0

Tak, w formacie EF.

<add name="TimerConn" connectionString="metadata=res://*/Model.TTModel.csdl|res://*/Model.TTModel.ssdl|res://*/Model.TTModel.msl;
         provider=System.Data.SqlClient;          
         provider connection string=&quot;
         data source=************,8123\BPSAPPLICATIONSE;
         initial catalog=HP_TIMER_TOOL; 
         persist security info=True;Integrated Security=True;
         multipleactiveresultsets=True;
         application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

(***** - musialem to tak wrzucic - restrykcje klienta)

z DbContext.

0

Hmmm, właśnie wyrzuciłem metodę którą odpalał DispatcherTimer i....Designer wrócił do normy. Nie ma żadnych błędów.

Metoda była async, czy w takim razie async będzie miał jakiś wpływ na designer?? (!!)

Z góry dzięki

1

pewnie tworzyłeś tego dispatchertimera w konstruktorze klasy
cały kod z konstruktora normalnie się wykonuje podczas pracy designera

1 użytkowników online, w tym zalogowanych: 0, gości: 1