EDMX and bridge table using oracle database - asp.net

I have an oracle database connected to ASP.net MVC 5 with entity framework 6 application, all things was going well, until i made a change (add a new column) in bridge table:
the table:
my constraint on table :
Sample of data:
Error::
Severity Code Description Project File Line Suppression State
Error Error 3025: Problem in mapping fragments starting at line 4758:Must specify mapping for all key properties (DECC_TAB_SUB.TAB_ID, DECC_TAB_SUB.PARENT_TAB_ID, DECC_TAB_SUB.STEPROLE_ID) of table DECC_TAB_SUB. DECC.EntityModel
and here's the table in diagram
and here's the association
, I have made many searches but unfortunately i didn't find anything helps me.

Related

Reference another table in ASP.NET without a foreign key or joining tables

I have read-only access to a database. This database has multiple tables with status codes and one other reference table the gives a name for each code. These tables are not linked by a foreign key and I can't alter the database in any way. I'd like to display the status names in my web-app view instead of the numeric status code, is there a way to do this? Using EF Core 6
I tried to join the two tables but it didn't match the model in the View. I don't know how to remedy this situation without creating a new table (which I can't do)

How do I include a third party SQL table into a asp.net code first web application?

It would be nice to be able to access the third party table in the same ApplicationDbContext that is generated by code first. But ultimately I really want to be able to join on the table in a linq query that translates into a single sql query (dont want it to make two database calls because I am joining two database contexts)
The table is a zipcodes table purchased from a third party. It does not have a unique id as code first requires, so I would have to give it one i guess?
If you're not using Code First Migrations to manage the database, you could just create a model for the zip codes table. The EF model for the table and the table itself don't necessarily have to match, so you could create a class to represent a zip code table record, and set a key for the zip codes entity even if the database table itself doesn't have one. You would have to be sure that the chosen key is unique or you would get unexpected results.
If you're using Code First Migrations, the same thing applies, but you can also run the SQL script itself in a DbMigration or in the DbMigrationsConfiguration.Seed.

Entity framework error "Invaid column name" while update record after renaming table

I am using asp.net 4.5 with EF to add/update/delete record.
I renamed a database table StatusMaster to Status.
To reflect this change in entity, I have used "update model from database" in which I have deleted the table first.
Then I have deleted the table from the diagram using "Delete Model".
Then I added table to the edmx file using "Update Model from Database".
I also have update related code in application.
Now Add() method is working well but while update method it gives me error "Invalid column name 'Id'". This column was the primary key before I update but I have also renamed it to "StatusId" but I don't think it should affect it because I already have deleted and added the table using "Update model from database".
Please help me.
All the more reason I prefer code first. More work to set up but easier to make changes down the line. Ill suggest you do the following.
Delete the entire EDMX
Delete Connection Details from config section in Web.config
Re-Create EDMX
I discovered that is faster that trying to debug ur relationship in the EDMX diagram

EF Code First, no edmmetadata table

I am reading through the book EF Code First by Julie Lerman. In the book, a database is created which contains tables generated from the domain model, as well a table named edmmetadatatable. Apparently, this table is needed for checking if there are any changes made to the other tables.
But, I don't have it. And I don't know how to get it.
One thing I did differently from the book was that I added my own connection string since code first defaults for SQLEXPRESS and I don't have SQLEXPRESS.
The book is covering Entity Framework 4.2 which uses the EdmMetadata table. When migrations were introduced in EF 4.3, a __MigrationHistory table was introduced instead.
See here for more information.

Can not make generateChangeLog working in liquibase to export data from existing database

I read some similar questions, but I still can not figure out how to export data or schemas from an exiting database using liquibase. The database i am using is sqlite, and I always got problem.
java -jar liquibase-1.9.3.jar --driver=org.sqlite.JDBC --classpath=lib/sqlite-jdbc-3.7.2.jar --changeLogFile=test.data --url=jdbc:sqlite:test.db --diffTypes="data" generateChangeLog
the error is: Migration Failed: no such column: 'DECIMAL_POINTS'
I just have a testing table with 2 fields: ID (integer type), and name (VARCHAR type).
Can somebody help? Thanks.
I couldn't find more examples about using liquibase with sqlite database. So, I tested and figured out by myself, and commented below:
You need to pick up right jdbc engine for liquibase, when I changed sqlitejdbc engine from sqlite-jdbc-3.7.2.jar to sqlitejdbc-v056.jar (http://www.zentus.com/sqlitejdbc/), it works. So it is important to pick up right one.

Resources