Only Allow Schema Change from Backendless Console - backendless

I want to restrict creating or modifying the data model schema for backendless. Specifically, only want to create or modify the data model schema using the console. The data model schema should not be modified using the API.
How can this be achieved?

It this point it can be achieved by you making sure that your code stays consistent and does not introduce new fields/properties. Adding a new field to a class and then saving an instance of the class with the API will result in a new column being created. So to avoid that make sure that your classes at any point of time represent the schema of the backend.

Related

How to access the table AspNetUserRoles generated by ASP identity?

I am coding an API that uses the Identity feature on asp.net and right now I am trying to make a method that returns all the couples ( user.id, role.id ) which are stored on the table AspNetUserRoles when assigning a role to a user.
One solution would be to get the full list of users and find each role of that user in a double loop but having too much data, it wouldn't be optimal for my case. The perfect solution for me would be to access that table directly which contains exactly what I am looking for
Thanks for the help!
You will have to create class models and relationships explicitly as described in the documentation below:
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/customize-identity-model?view=aspnetcore-3.1#add-user-and-role-navigation-properties
This documentation expects you to at least create the ApplicationUser, ApplicationRole and ApplicationUserRole class models. Also, you will have to update your DBContext accordingly to correctly use the new models that you create. The names for the models can be changed. However, in any case, this should not change any DB schema and will not require any EF migrations.
Lastly,

A few questions regarding importing a manually created data entity

I used the data entity creation wizard and selected Reqplan table as the main data source, then I manually added ReqPlanVersion, ReqPO, ReqTrans table as additional data sources and created the relationships below.
As for the data entities fields I manually dragged a subsets of fields from the three manually added tables.
However when I try to import the data and add file, I receive the following issue:
Q1. In the past for some other entities I have changed ‘Allow Edit on Create’ from ‘Auto’ to ‘YES’ on these fields and it has worked but I am not sure if it’s the only way or is it following best practice? Also what is the determining factor for a field to be editable or not during import since they are all on AUTO?
When I try to map source to staging manually by drawing the mapping lines I get below issue:
Q2. What is going on with the configuration key? Is it because I manually dragged the fields from the additional data sources but not using the data entity creation wizard?
Lastly I been getting below issue:
Q3: Is there a way to find out which unique key it is referring to? Is it talking about the EntityKey in my Data Entity or Indexes in staging table? In either case there are more than one so I am not sure what it is referring to?
Thanks in advance.
Response from the community forum:
1) Check allowEdit property on table itself, so if it is "No" there then auto means "No". If you want to update them through data entity you will have to force them to "Yes"
2) It's not connected to manual addition, it just says that tables used in the entity has configuration key disabled, so you cannot export or import data into them, however, these tables could be added by wizard or manually, it does not matter. Also, Configuration key could be on fields as well or on EDT that these fields use, check them as well.
3) Entity has Key node and there and there you have key generated by wizard for you. It is used by framework to understand if record should be updated or created, if it does not work for you, change it on the data entity and regenerate staging. You need to refresh staging because error you get is SQL error, at this stage SSIS transfers data from a file into a staging table and data could not be copied because of index vialotion, so check staging table index and see if your file has any duplicates.

Symfony Mapping in Doctrine without Annotations or XML Files

a customer has an existing database. The schema is often changed within the database itself (e.g. he adds a new column).
My task is to develop an admin area with symfony that automatically reacts on table schema changes without modifying the application code. E.g. the customer adds a new column to table "MyEntity", and the application automatically generates a new column in the accordingly list view.
My approach is to dynamically map the table columns to the Entity class so that ALL Attributes and ALL Getters/Setters are generated dynamically from the table schema.
So is it possible to map the table columns in a Doctrine Entity without the use of Annotations or XML Files.
Something like:
class MyEntity{
public function generateMappingFromSchema($sTableName){...}
}
Please don't do that. Doctrine was not designed for such use case.
There is a library though you should check https://github.com/laravel-doctrine/fluent which basically is a mapping driver that allows you to manage your mappings in an Object Oriented approach. And there are other tools:
http://crud-admin-generator.com/
http://crudkit.com/
http://www.grocerycrud.com/
which are maybe better for that, I don't know.
But again, please don't do that. Do not allow the customer to modify the database schema or give them e.g. a phpMyAdmin which was designed for that.

Entity Framework update issue

I am not sure if it's a bug, but when i add a new view or a new stored procedure to the model it updates all the tables that exist. So my question is should it work like this and if it should how can i add some new procedure without updating the whole model?
Yes, this is the correct functionality when using the "Update Model" function for EntityFramework. It looks at every database object and updates the EF Model to match what it finds in the database. This is, in part, because the designer does not let you specifically choose which tables or view to update, so it verifies any changes in the database. This allows the model to proactively ensure that when it connects to the database there won't be an error based on the database changing.

How do I define a database view using Entity Framework 4 Code-First?

How do I define a database view using Entity Framework 4 Code-First? I can't find anything about this anywhere!
That's because you cannot define database view using code-first approach. Database view is database construct which uses SQL Query on top of existing tables / functions. You can't define such constructs using code first.
If you want view you must create it manually by executing CREATE VIEW SQL script for example in custom initializer - it will be similar like this answer. Just be aware that this will not help you if you want to map entity to a view. In such case you would probably have to first drop table created by EF and create view with the same name (I didn't try it but it could do the trick). Also be aware that not every view is udpatable so you will most probably get read only entity.
To do a view you create the model, then in the initializer you run the SQL statement to create the view directly against the context with the first line of code, and then in the context you override OnModelCreating and run the second line of code to ignore the model.
context.Database.ExecuteSqlCommand(Resources.<resourcename>);
modelBuilder.Ignore<modeltype>();

Resources