CoreData question - core-data

I have created application with corde data model to populate my sqlite database with data. What I want to put this populated database to iphone application. In iphone application project I have added the sqlite database file that I had populated and have imported the mangedobjectmodel from my destktop application, but when I run the iphone application I get an error : reason = "The model used to open the store is incompatible with the one used to create the store";
Is it possible to use one managedobjectmodel in different applications, or I have to migrate the data from one managedobjectmodel to another.
Thank you for your help.

The exact model used to create the store must be available to the app. The model provides the only information that the Core Data stacks has to interpret the store as objects.
You must move the model from the MacOS app to the iOS app. If you need to change the model, you need to create a new version of the old model and then migrate the store from the old to the new.
This is actually easy to do. I quite often create models and pre-populated SQLite stores on my development Mac and then insert the results into an iOS app. Unless your making any changes as above, the process is seamless and no more difficult than importing the files into the project.

Related

How To Pass Data From Database Apps To Theme App Extensions Without Metafield?

I am trying to figure out how to pass data between database apps to theme app extensions. In backend, Merchant can create, edit and delete data and it will update database. I also try using Metafield in Product, but when I want to assign metafield to multiple products, it take too much time to save metafield in every product.
How can I pass data from Database to Theme App Extension to update latest data to display on Online Store?
My theme app extension as below:
(https://i.stack.imgur.com/aQ4CD.png)
https://i.stack.imgur.com/UJ8De.png
You have two choices. One, the obvious one, is using Liquid, and rendering your custom data using Liquid, which implies, Metafields. You say that takes too much time, but the reality is, that is by far the best way.
Your second option is to use an App Proxy. It is slower, and prone to network problems obviously, but it does allow your extension to access data from the App's database.
Hope that helps.

How to build vue views from within electron apps to mount as plugins

I am writing a reporting app that runs in electron. Reporting means I have a data source and users write views that arrange the data in whichever ways they like so it can be printed out or archived as PDF.
Let's say there is a list of student data along with grades for courses. The reporing app allows you to create a report that has a data table with names and grades for each course. So you end up with grade reports. Someone else wants just names and addresses another one wants to create a library card for each student. HTML and CSS combined with Vue make a great foundation to write this stuff.
The easy part is to fetch data from the database and offer json as a data source to views. The difficult part is how to let users add their reports to the app. In dev mode I can just add views to directories, import them and render the data as part of the app. But I have my views available at build time. Once I have built and shipped the production app it's out of my hands and the user can't add their views to the app anymore because they don't rebuild the app. They just want to point to a directory, add their views and use them.
I have decided to use single file components because they allow users to simply add calculations and maybe use pug etc to keep it simple. Besides I can store data about the component in a straight forward way (like name of report, department etc)
To my knowledge I need to build those views programmatically and load them dynamically.
So my questions are:
How can I build and mount single file components (.vue) dynamically
from within a production app that has no prior knowledge of user
produced files?
Do I need to build these components or is there a way to utilize on board tools to just read and render these components?
Is there a better way to serve these files?
More information:
Security is not a concern. So loading user created views is ok. It needs to be working in electron. I do have a server based app written in Ruby that does the same thing but the server is going away anytime soon so it has to be client based and executable. I cannot install node on client PCs so they could just build their own app and include their own views via hot reloading.
If you're interested in reporting apps there is one in JS but server based: https://jsreport.net/ or mine, ruby based: https://github.com/hmt/sahib
You could watch the directory and respond to new files being add. That's for the dynamic part of your question. A nice way is node-fs.
Using the same lib you can serialize and deserialize object to or from file, letting you load the file from your user.
At this point, you only need to be able to change back and forth from an object to a Vue component. As far As I know, this is no problem as you can
new Vue (object)

MVC 4 unable to perform scaffolding

I'm new to MVC, and my intention actually is to learn 'Code First' technique, using MVC 4. I'd been through several 'MVC 4 Entity Framework' tutorials, and no doubt, tutorials are really simple, and understandable. but for every tutorial I followd, the
EF will look for the database in the default location and if it doesn’t exist, it will create it for you
part is not working for me. Do i have to add ADO.net Entity framework model in project, and design the database entities firt? or am I missing something? It's been more than 15 days, & I'm stuck.
(I tried making database manually first, and it worked perfect. But I want to learn, as described in tutorials, that databases are automatically created, if we mention the connection string, and EntityFramework finds out that path doesn't actually contains such database, so it creates one).
I'd been through several tutorials, let's say, I'm following THIS one.
(I'm using Visual Studio Express for web 2012, EF 5.0.0)
your question: Do i have to add ADO.net Entity framework model in project, and design the database entities firt?
yes, in code first approach you need to tell entity framework what tables you are going to create, you do it by creating poco classes(Plain old CLR Object). then in run time entity framework will create a model(witch is a xml file) and generate query according to that xml file then executes it. you can read more about that in [CSDL MSL CSDL][1]
so for summary you write your domain classes(poco classes) and ef will create db for you but btw there is another way where in entity framework code first witch is called [Code first to existing database][2]
[2]: http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx it revers engineer the databse and create model for you.
Do i have to add ADO.net Entity framework model in project, and design the database entities first?
This is really the more traditional approach, aptly called the database-first approach. The code-first approach is an alternative to the former. They mean exactly what they say. In the case of code-first the code is first written and in effect the database is generated automatically. In database approach, the database is first created then you can use EF to automatically generate the code required to handle the database, mainly CRUD and connection management.
The built-in scaffolder in ASP.NET MVC should work fine either in code-first or database-first as long as you have your models already established in your project. If you find the generated code too simplistic, an alternative scaffolder that you can use is CamoteQ - it is an online ASP.NET MVC scaffolding tool that is based in DDD principles and recognized patterns.

Problems with integrating DB with MVC 5

i am building a ticketing system which customers can add new tickets to the system and employees can help them with there requests. I built the data base with an ADO file and my question is, is it possible to use the identity user and all of the database that comes with the mvc5 web application yet add additional tables with connections. i have been trying to do this for a while with no success.
!(http://postimg.org/image/v49eh3gql/) this is my database and i would like to extend application user and use my other attributes as well as my other tables and the roles table that comes with mvc all in one database.
any help would be appreciated
cheers :)
You could use the same database but I think its better to keep them apart. Add the properties for your user entity to IdentityModels.Cs and to the AccountViewModels.cs where appropriate. Since the views for these viewmodels are already created you have to add the attributes to the view yourself. Then in the package manager console Enable-Migrations Copy and paste the command that has the applicationDbConted in it. Add-Migration -Init then run Update-Database
Here is a post about how to access the logged in user.
is it possible to use the identity user and all of the database that comes with the mvc5 web application yet add additional tables with connections.
In other words, can you have an application with database first and model first?
Yes, but you have to be careful that you don't migrate the database first dbcontext.

VS 2012 EF 5 using .net 4 and database first Layered applications concepts

I upgraded from VS2005 to VS2012 specifically to code in .Net 4,.Net 4.5, and use EF5. I am new to EF. I have Julie's EF book but it talks mainly about EF4 and POCO and it has me confused trying to implement EF5.
My hosting only allows me to run .Net 4 currently. I am trying to use EF5 on a new database.
I tried Code first to generate my database but I could not get it to generate the database. So I created the database first and then generated the model from the database with EF5. What I want is a layered website using ASP.NET Forms, Data Access Layer, and a Business Layer. The business layer I intend to build so I can use ObjectDataSource to pull in to the webpage along with some web services to use cascading dropdowns.
I have my NameX.edm model created but the tt files don't have the same names, they have Model1.tt and Model1.Context.tt is not the same name, why. Also Model1.Context.tt is empty. I am attempting to create the POCO classes running the EF5 DbContext but I am having trouble getting it to see the edm model. I read somewhere that EF5 creates the POCO automatically. I am not seeing the big picture here. Is my issue that I am not using .Net4.5?
What I have is a ASP.NET Application project, a EF Project, a POCO Project, and intend to have a forth project with the Business logic. How do I get the EF generated correctly and the POCO classes? I want a layered application for to scale well. Next question How to get the POCO classes to talk with the Business logic? My database is SQL. I am use to writing stored proceedures to accomplish everything through business logic.
If you are using Model First technique, make sure that you have references to System.Data.Entity and System.Data.Entity.Design. Also, you will need to create a reference to the EntityFramework.dll as well. It is located by default in c:\Program Files\Microsoft ADO.NET Entity Framework Feature CTP5\Binaries\EntityFramework.dll. If you can not find it, make sure you have installed the Entity Framework through your Package Manager Console. To do this, open up Tools, Library Package Manager, Package Manager Console, then type Install-Package EntityFrameWork.
Next you want to add a new item to your project. Right click on your solution, go to Add, then select New Item. You want to select Data from the Common Items section on the left, then select ADO.NET Entity Data Model.
Next Select Generate From Database. In the next screen, if you have not set up your connection to the server, click New Connection..., otherwise select your database from the drop down box. You need to select whether or not you want to include your connection string information in your config file. This is up to you how secure you need your application to be. If you choose not to, you need to pass this information as parameters in code. Also at the bottom, you will most likely want to change the auto-generated entities name to something easier for you to use. This name will be the name of your DBContext Class!
Next you want to select the tables you would like EF to create POCO's for. If you want all the tables just tick the tables items. Same goes for views and stored procs.
Once you click finish, then you should see all your fancy POCOS laid out in front of you in Design Mode. Note If you do not have primary keys in place for all your tables, I suggest you fix that! VS will spit at you if you do not have Primary Keys set, or if your naming conventions in your tables prevent VS from creating them for you implicitly.
This is a quick little tutorial on getting you up and running. You can now persist and pull data from your POCOS by using your DBContext object. For example if you named your DBContext class *Gary_Bettman_Sucks*, and you wanted to create a new record from your table called NHL you would do the following:
Dim context as New Gary_Bettman_Sucks
Dim PullMyGoalie as New NHL With {
.Goals = 0,
.Playoffs = False
}
context.Set(Of NHL).Add(PullMyGoalie)
context.SaveChanges()
I would Highly suggest you look into implementing the Repository Pattern with your design to encourage code re-use, and it will seriously make your life MUCH easier down the road.
Hope this helps!

Resources